AVR-LibC  2.2.1
Standard C library for AVR-GCC

AVR-LibC Documentation

Logo

AVR-LibC Development Pages

Main Page

User Manual

Library Reference

FAQ

Example Projects

File List

Loading...
Searching...
No Matches
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 dtostre() function, compiled with avr-gcc 3.4.6, requires 930 bytes. After transition to avr-gcc 4.2.3, the size become 1088 bytes.

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.

FunctionUnitsAvr2Avr25Avr4
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.

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