1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
Bit Operations:
i1>>1 2.04
i1<<1 2.11
i1>>3 2.1

Int Operations:
i1++ 2.43
i1 = i2 + i3 2.09
i1 = i2 - i3 2.13
i1 = i2 * i3 2.11
i1 = i2 / i3 3.3
i1 = i2 % i3 3.33

Float Operations:
f1 = f2 + f3 2.1
f1 = f2 - f3 2.13
f1 = f2 * f3 2.1
f1 = f2 / f3 2.36

Double Operations:
d1 = d2 + d3 2.12
d1 = d2 - d3 2.09
d1 = d2 * d3 2.14
d1 = d2 / d3 4.75

Numeric Conversions:
i1=(int)f1 2.36
i1=(int)d1 2.37
f1=(float)i1 2.34

Math Functions:
i1 = rand() 9.02
f1 = log(f2) 17.51
f1 = exp(f2) 16.26
f1 = sin(f2) 16.06
f1 = cos(f2) 15.65
f1 = sqrt(f2) 5.3

Fun Call:
fun1() 2.13
i1 = fun2() 2.16
i1 = fun3(i1) 2.44
i1 = fun4(i1, i2, i3) 2.8
if ( i1 == 5) 2.02
if ( i1 > 5) 2.03
if ( i1 != 5) 2.03

Malloc:
free(malloc(8)) 23.65

String Functinos:
i1 = strlen(str1) 2.97
strcpy(str2, str1) 4.03
i1 = strcmp(str2, str1) 2.98

String/Number Conversions:
i1 = atoi("12345") 17.61
sscanf("12345", "%d", &i1) 88.85
sprintf(s, "%d", i) 83.72
f1 = atof("123.45") 105.77
sscanf("123.45", "%f", &f1) 196.67
sprintf(s, "%6.2f", 123.45) 401.93

Input/Ouput:
fprintf(fp, "%d\n", i1) 108.04

Mutex Operations:
pthread_mutex_lock(&mutex_);pthread_mutex_unlock(&mutex_) 3.99

参考

  1. http://mingxinglai.com/cn/2012/12/estimate-value-of-time-in-c/

留言

2016-11-02