benchmarks(3)

NAME
benchmarks - Benchmarks The results below can only give a rough estimate of the resources necessary for using certain library functions. There is a number of factors which can both increase or reduce the effort required:

•   Expenses for preparation of operands and their stack are not considered.
•   In the table, the size includes all additional functions (for example, function to multiply two integers) but they are only linked from the library.
•   Expenses of time of performance of some functions essentially depend on parameters of a call, for example, qsort() is recursive, and sprintf() receives parameters in a stack.
•   Different versions of the compiler can give a significant difference in code size and execution time. For example, the float version of sscanf() function, compiled with avr-gcc 3.4.6, requires 3792 bytes and uses 124 bytes of stack. After transition to avr-gcc 4.2.2, the size become 3886 bytes, using 140 bytes of stack.

A few of libc functions.
Avr-gcc version is 4.2.2
 Function Units Avr2 Avr25 Avr4 atoi ('12345') Flash bytes
Stack bytes
MCU clocks 82
2
155 78
 74
2
149 atol ('12345') Flash bytes
Stack bytes
MCU clocks 122
2
221 118
 118
2
219 dtostre (1.2345, s, 6, 0) Flash bytes
Stack bytes
MCU clocks 1184
17
1313 1088
 1088
17
1152 dtostrf (1.2345, 15, 6, s) Flash bytes
Stack bytes
MCU clocks 1676
36
1608 1548
 1548
36
1443 itoa (12345, s, 10) Flash bytes
Stack bytes
MCU clocks 150
4
1172 134
 134
4
1152 ltoa (12345L, s, 10) Flash bytes
Stack bytes
MCU clocks 220
9
3174 200
 200
9
3136 malloc (1) Flash bytes
Stack bytes
MCU clocks 556
4
197 508
 508
4
179 realloc ((void *)0, 1) Flash bytes
Stack bytes
MCU clocks 1156
20
304 1046
 1046
20
281 qsort (s, sizeof(s), 1, cmp) Flash bytes
Stack bytes
MCU clocks 1242
38
20914 990
 1008
38
16678 sprintf_min (s, '%d', 12345) Flash bytes
Stack bytes
MCU clocks 1216
59
1846 1090
 1086
59
1711 sprintf (s, '%d', 12345) Flash bytes
Stack bytes
MCU clocks 1674
58
1610 1542
 1498
58
1528 sprintf_flt (s, '%e', 1.2345) Flash bytes
Stack bytes
MCU clocks 3334
66
2513 3084
 3040
66
2297 sscanf_min ('12345', '%d', &i) Flash bytes
Stack bytes
MCU clocks 1528
60
1743 1378
 1390
60
1456 sscanf ('12345', '%d', &i) Flash bytes
Stack bytes
MCU clocks 1880
62
1849 1724
 1694
62
1561 sscanf_flt ('1.2345', '%e', &x) Flash bytes
Stack bytes
MCU clocks 4250
140
3131 3916
 3886
140
2756 strtod ('1.2345', &p) Flash bytes
Stack bytes
MCU clocks 1638
22
1273 1550
 1514
22
1012 strtol ('12345', &p, 0) Flash bytes
Stack bytes
MCU clocks 956
29
1081 888
 822
21
729

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) 4648 2689 asin (0.54321) 4754 2790 atan (0.54321) 4710 2271 atan2 (1.234, 5.678) 5270 2857 ceil (1.2345) 177 177 cos (1.2345) 3381 1665 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) 132 132 frexp (1.2345, 0) 37 36 hypot (1.234, 5.678) 1556 1078 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) 3347 1647 sinh (1.2345) 4946 3003 sqrt (1.2345) 709 704 tan (1.2345) 4375 2420 tanh (1.2345) 5126 3173 trunc (1.2345) 178 178