benchmarks(3) Benchmarks

A few of libc functions.

Avr-gcc version is 4.7.1

The size of function is given in view of all picked up functions. By default Avr-libc is compiled with -mcall-prologues option. In brackets the size without taking into account modules of a prologue and an epilogue is resulted. Both of the size can coincide, if function does not cause a prologue/epilogue.


 Function Units Avr2 Avr25 Avr4  atoi ('12345') Flash bytes
Stack bytes
MCU clocks 82 (82)
2
155 78 (78)
2
149 74 (74)
2
149 atol ('12345') Flash bytes
Stack bytes
MCU clocks 122 (122)
2
221 118 (118)
2
219 118 (118)
2
219 dtostre (1.2345, s, 6, 0) Flash bytes
Stack bytes
MCU clocks 1116 (1004)
17
1247 1048 (938)
17
1105 1048 (938)
17
1105 dtostrf (1.2345, 15, 6, s) Flash bytes
Stack bytes
MCU clocks 1616 (1616)
38
1634 1508 (1508)
38
1462 1508 (1508)
38
1462 itoa (12345, s, 10) Flash bytes
Stack bytes
MCU clocks 110 (110)
2
879 102 (102)
2
875 102 (102)
2
875 ltoa (12345L, s, 10) Flash bytes
Stack bytes
MCU clocks 134 (134)
2
1597 126 (126)
2
1593 126 (126)
2
1593 malloc (1) Flash bytes
Stack bytes
MCU clocks 768 (712)
6
215 714 (660)
6
201 714 (660)
6
201 realloc ((void *)0, 1) Flash bytes
Stack bytes
MCU clocks 1284 (1172)
18
305 1174 (1064)
18
286 1174 (1064)
18
286 qsort (s, sizeof(s), 1, cmp) Flash bytes
Stack bytes
MCU clocks 1252 (1140)
42
21996 1022 (912)
42
19905 1028 (918)
42
17541 sprintf_min (s, '%d', 12345) Flash bytes
Stack bytes
MCU clocks 1224 (1112)
53
1841 1092 (982)
53
1694 1088 (978)
53
1689 sprintf (s, '%d', 12345) Flash bytes
Stack bytes
MCU clocks 1614 (1502)
58
1647 1476 (1366)
58
1552 1454 (1344)
58
1547 sprintf_flt (s, '%e', 1.2345) Flash bytes
Stack bytes
MCU clocks 3228 (3116)
67
2573 2990 (2880)
67
2311 2968 (2858)
67
2311 sscanf_min ('12345', '%d', &i) Flash bytes
Stack bytes
MCU clocks 1532 (1420)
55
1607 1328 (1218)
55
1446 1328 (1218)
55
1446 sscanf ('12345', '%d', &i) Flash bytes
Stack bytes
MCU clocks 2008 (1896)
55
1610 1748 (1638)
55
1449 1748 (1638)
55
1449 sscanf ('point,color', '%[a-z]', s) Flash bytes
Stack bytes
MCU clocks 2008 (1896)
86
3067 1748 (1638)
86
2806 1748 (1638)
86
2806 sscanf_flt ('1.2345', '%e', &x) Flash bytes
Stack bytes
MCU clocks 3464 (3352)
71
2497 3086 (2976)
71
2281 3070 (2960)
71
2078 strtod ('1.2345', &p) Flash bytes
Stack bytes
MCU clocks 1632 (1520)
20
1235 1536 (1426)
20
1177 1480 (1480)
21
1124 strtol ('12345', &p, 0) Flash bytes
Stack bytes
MCU clocks 918 (806)
22
956 834 (724)
22
891 792 (792)
28
794

Math functions.

The table contains the number of MCU clocks to calculate a function with a given argument(s). The main reason of a big difference between Avr2 and Avr4 is a hardware multiplication.

Function Avr2 Avr4 __addsf3 (1.234, 5.678) 113 108 __mulsf3 (1.234, 5.678) 375 138 __divsf3 (1.234, 5.678) 466 465 acos (0.54321) 4411 2455 asin (0.54321) 4517 2556 atan (0.54321) 4710 2271 atan2 (1.234, 5.678) 5270 2857 cbrt (1.2345) 2684 2555 ceil (1.2345) 177 177 cos (1.2345) 3387 1671 cosh (1.2345) 4922 2979 exp (1.2345) 4708 2765 fdim (5.678, 1.234) 111 111 floor (1.2345) 180 180 fmax (1.234, 5.678) 39 37 fmin (1.234, 5.678) 35 35 fmod (5.678, 1.234) 131 131 frexp (1.2345, 0) 42 41 hypot (1.234, 5.678) 1341 866 ldexp (1.2345, 6) 42 42 log (1.2345) 4142 2134 log10 (1.2345) 4498 2260 modf (1.2345, 0) 433 429 pow (1.234, 5.678) 9293 5047 round (1.2345) 150 150 sin (1.2345) 3353 1653 sinh (1.2345) 4946 3003 sqrt (1.2345) 494 492 tan (1.2345) 4381 2426 tanh (1.2345) 5126 3173 trunc (1.2345) 178 178