测试机器:Intel(R) Core(TM)2 双核, 2.40GHz, memory: 8G
内容:
gettimeofday: 60ns
for(;;): 2.9ns
sprintf(): 1.7us [sprintf(buf,"ABCDEF%d",i)]
strcpy(): 18ns [size 10]
strcpy(): 69120us [size 100,000,000] = 6.9ns [size 10]
memcopy(): 43411us [size 100,000,000] = 4.3ns [size 10]
*d=*s: 4.3ns [char *d]
new: 40ns [new(16)]
string +=: 370368us [string +="ABCDEF1234", Total Size=100,000,000]
string.reserve(): 220050us [一次分配,测试和上述情况一样]
stringstream <<: 456982us [ <<"ABCDEF1234", Total Size=100,000,000]
string +=: 2664us [string +="ABCDEF1234", Total Size=1,000,000]
string.reserve(): 1940us [一次分配,测试和上述情况一样]
stringstream <<: 3595us [ <<"ABCDEF1234", Total Size=1,000,000]
string +=: 77us [string +="ABCDEF1234", Total Size=10,000]
string.reserve(): 20us [一次分配,测试和上述情况一样]
stringstream <<: 45us [ <<"ABCDEF1234", Total Size=10,000]
map
obj[str]=i: 326407us [1,000,000次]
map
obj[i]=i: 109307us [1,000,000次]
阅读(1116) | 评论(1) | 转发(0) |