mutex 性能测试:
公司报废笔记本dell E4300,Ubuntu 13.04系统
公司报废笔记本dell E4300,Ubuntu 13.04系统
mutex 加锁和解锁性能测试:
(加锁和解锁)过程,一亿次,共耗时:3883693微妙平均时间 (3888524 * 1000/100000000 = 38.88纳秒)
在我的台式机: AMD 1100T 6核心处理器,而且是VMware 虚拟机上:
gongbo@gongbo-virtual-machine:~$ ./mutex1.o
1762201
1762201
平均时间 (1762201 * 1000/100000000 = 17.62 纳秒)
公司生产环境的标准硬件上:
[admin@oceanbase074013 tmp]$ ./mutex1.o
2417836
// test
struct timeval dwStart;
struct timeval dwEnd;
unsigned long dwTime1=0;
unsigned long dwTime2=0;
int main(void)
{
struct foo *fp;
fp = foo_alloc();
gettimeofday(&dwStart,NULL);
for(int i=0;i< 100000000;i++)
{
pthread_mutex_lock(&fp->f