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:

A few of libc functions

Avr-gcc version is 4.2.3

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.

FunctionUnitsAvr2Avr25Avr4
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 (1072)
17
1313
1088 (978)
 
 
1088 (978)
17
1152
dtostrf (1.2345, 15, 6, s) Flash bytes
Stack bytes
MCU clocks
1676 (1564)
36
1608
1548 (1438)
 
 
1548 (1438)
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
554
4
196
506
 
 
506
4
178
realloc ((void*)0,1) Flash bytes
Stack bytes
MCU clocks
1152 (1040)
20
303
1042 (932)
 
 
1042 (932)
20
280
qsort (s,sizeof(s),1,cmp) Flash bytes
Stack bytes
MCU clocks
1242 (1130)
38
20914
990 (880)
 
 
1008 (898)
38
16678
sprintf_min (s,"%d",12345) Flash bytes
Stack bytes
MCU clocks
1216 (1104)
59
1846
1090 (980)
 
 
1086 (976)
59
1711
sprintf (s,"%d",12345) Flash bytes
Stack bytes
MCU clocks
1674 (1562)
58
1610
1542 (1432)
 
 
1498 (1388)
58
1528
sprintf_flt (s,"%e",1.2345) Flash bytes
Stack bytes
MCU clocks
3334 (3222)
66
2513
3084 (2974)
 
 
3040 (2930)
66
2297
sscanf_min ("12345","%d",&i) Flash bytes
Stack bytes
MCU clocks
1540 (1428)
55
1339
1354 (1244)
 
 
1354 (1244)
55
1240
sscanf ("12345","%d",&i) Flash bytes
Stack bytes
MCU clocks
1950 (1838)
53
1334
1704 (1594)
 
 
1704 (1594)
53
1235
sscanf ("point,color","%[a-z]",s) Flash bytes
Stack bytes
MCU clocks
1950 (1838)
87
2878
1704 (1594)
 
 
1704 (1594)
87
2718
sscanf_flt ("1.2345","%e",&x) Flash bytes
Stack bytes
MCU clocks
3298 (3186)
63
2187
2934 (2824)
 
 
2918 (2808)
63
1833
strtod ("1.2345",&p) Flash bytes
Stack bytes
MCU clocks
1570 (1458)
22
1237
1472 (1362)
 
 
1456 (1346)
22
971
strtol ("12345",&p,0) Flash bytes
Stack bytes
MCU clocks
942 (830)
29
1074
874 (764)
 
 
808 (698)
21
722

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.

FunctionAvr2Avr4
__addsf3 (1.234, 5.678) 113108
__mulsf3 (1.234, 5.678) 375138
__divsf3 (1.234, 5.678) 466465
acos (0.54321) 44112455
asin (0.54321) 45172556
atan (0.54321) 47102271
atan2 (1.234, 5.678) 52702857
cbrt (1.2345) 26842555
ceil (1.2345) 177177
cos (1.2345) 33871671
cosh (1.2345) 49222979
exp (1.2345) 47082765
fdim (5.678, 1.234) 111111
floor (1.2345) 180180
fmax (1.234, 5.678) 3937
fmin (1.234, 5.678) 3535
fmod (5.678, 1.234) 131131
frexp (1.2345, 0) 4241
hypot (1.234, 5.678) 1341866
ldexp (1.2345, 6) 4242
log (1.2345) 41422134
log10 (1.2345) 44982260
modf (1.2345, 0) 433429
pow (1.234, 5.678) 92935047
round (1.2345) 150150
sin (1.2345) 33531653
sinh (1.2345) 49463003
sqrt (1.2345) 494492
tan (1.2345) 43812426
tanh (1.2345) 51263173
trunc (1.2345) 178178