benchmarks(3avr)
β¨ NAME β¨
benchmarks β Benchmarks, bestie. That's it, that's the name. We're in the 3avr part of the AVR-LibC manual, and this page is the receipts: how many flash bytes, stack bytes and MCU clocks certain library functions are gonna cost you. π
okay so real talk: the results below can only give a rough estimate of the resources necessary for using certain library functions. There's a whole list of factors that can either increase or reduce the effort required, and you need to know all of them:
- expenses for preparation of operands and their stack are not considered π
- in the table, the size includes all additional functions (for example, the function to multiply two integers) β but they are only linked from the library
- expenses of time of performance of some functions essentially depend on the parameters of a call. for example,
qsort()is recursive, andsprintf()receives its parameters in a stack. it's giving chaos π - different versions of the compiler can give a significant difference in code size and execution time. for example, the
dtostre()function, compiled withavr-gcc 3.4.6, requires930bytes. after the transition toavr-gcc 4.2.3, the size become1088bytes. not me sobbing in hex π
π A few of libc functions π
Avr-gcc version is 4.7.1 π
The size of a function is given in view of all picked up functions. By default AVR-LibC is compiled with the -mcall-prologues option. In brackets, the size without taking into account modules of a prologue and an epilogue is resulted. Both of the sizes can coincide, if the function does not cause a prologue/epilogue. no cap.
so the layout is: each function, then Units (Flash bytes, Stack bytes, MCU clocks), and then the number for Avr2, Avr25 and Avr4 β in that order, every time, periodt.
atoi ("12345")- Flash bytes: Avr2
82 (82), Avr2578 (78), Avr474 (74) - Stack bytes: Avr2
2, Avr252, Avr42 - MCU clocks: Avr2
155, Avr25149, Avr4149
- Flash bytes: Avr2
atol ("12345")- Flash bytes: Avr2
122 (122), Avr25118 (118), Avr4118 (118) - Stack bytes: Avr2
2, Avr252, Avr42 - MCU clocks: Avr2
221, Avr25219, Avr4219
- Flash bytes: Avr2
dtostre (1.2345, s, 6, 0)- Flash bytes: Avr2
1116 (1004), Avr251048 (938), Avr41048 (938) - Stack bytes: Avr2
17, Avr2517, Avr417 - MCU clocks: Avr2
1247, Avr251105, Avr41105
- Flash bytes: Avr2
dtostrf (1.2345, 15, 6, s)- Flash bytes: Avr2
1616 (1616), Avr251508 (1508), Avr41508 (1508) - Stack bytes: Avr2
38, Avr2538, Avr438 - MCU clocks: Avr2
1634, Avr251462, Avr41462
- Flash bytes: Avr2
itoa (12345, s, 10)- Flash bytes: Avr2
110 (110), Avr25102 (102), Avr4102 (102) - Stack bytes: Avr2
2, Avr252, Avr42 - MCU clocks: Avr2
879, Avr25875, Avr4875
- Flash bytes: Avr2
ltoa (12345L, s, 10)- Flash bytes: Avr2
134 (134), Avr25126 (126), Avr4126 (126) - Stack bytes: Avr2
2, Avr252, Avr42 - MCU clocks: Avr2
1597, Avr251593, Avr41593
- Flash bytes: Avr2
malloc (1)- Flash bytes: Avr2
768 (712), Avr25714 (660), Avr4714 (660) - Stack bytes: Avr2
6, Avr256, Avr46 - MCU clocks: Avr2
2157, Avr252017, Avr42017
- Flash bytes: Avr2
realloc ((void *)0, 1)- Flash bytes: Avr2
1284 (1172), Avr251174 (1064), Avr41174 (1064) - Stack bytes: Avr2
18, Avr2518, Avr418 - MCU clocks: Avr2
3051, Avr252861, Avr42861
- Flash bytes: Avr2
qsort (s, sizeof(s), 1, cmp)- Flash bytes: Avr2
1252 (1140), Avr251022 (912), Avr41028 (918) - Stack bytes: Avr2
42, Avr2542, Avr442 - MCU clocks: Avr2
21996, Avr2519905, Avr417541
- Flash bytes: Avr2
sprintf_min (s, "%d", 12345)- Flash bytes: Avr2
1224 (1112), Avr251092 (982), Avr41088 (978) - Stack bytes: Avr2
53, Avr2553, Avr453 - MCU clocks: Avr2
1841, Avr251694, Avr41689
- Flash bytes: Avr2
sprintf (s, "%d", 12345)- Flash bytes: Avr2
1614 (1502), Avr251476 (1366), Avr41454 (1344) - Stack bytes: Avr2
58, Avr2558, Avr458 - MCU clocks: Avr2
1647, Avr251552, Avr41547
- Flash bytes: Avr2
sprintf_flt (s, "%e", 1.2345)- Flash bytes: Avr2
3228 (3116), Avr252990 (2880), Avr42968 (2858) - Stack bytes: Avr2
67, Avr2567, Avr467 - MCU clocks: Avr2
2573, Avr252311, Avr42311
- Flash bytes: Avr2
sscanf_min ("12345", "%d", &i)- Flash bytes: Avr2
1532 (1420), Avr251328 (1218), Avr41328 (1218) - Stack bytes: Avr2
55, Avr2555, Avr455 - MCU clocks: Avr2
1607, Avr251446, Avr41446
- Flash bytes: Avr2
sscanf ("12345", "%d", &i)- Flash bytes: Avr2
2008 (1896), Avr251748 (1638), Avr41748 (1638) - Stack bytes: Avr2
55, Avr2555, Avr455 - MCU clocks: Avr2
1610, Avr251449, Avr41449
- Flash bytes: Avr2
sscanf ("point,color", "%[a-z]", s)- Flash bytes: Avr2
2008 (1896), Avr251748 (1638), Avr41748 (1638) - Stack bytes: Avr2
86, Avr2586, Avr486 - MCU clocks: Avr2
3067, Avr252806, Avr42806
- Flash bytes: Avr2
sscanf_flt ("1.2345", "%e", &x)- Flash bytes: Avr2
3464 (3352), Avr253086 (2976), Avr43070 (2960) - Stack bytes: Avr2
71, Avr2571, Avr471 - MCU clocks: Avr2
2497, Avr252281, Avr42078
- Flash bytes: Avr2
strtod ("1.2345", &p)- Flash bytes: Avr2
1632 (1520), Avr251536 (1426), Avr41480 (1480) - Stack bytes: Avr2
20, Avr2520, Avr421 - MCU clocks: Avr2
1235, Avr251177, Avr41124
- Flash bytes: Avr2
strtol ("12345", &p, 0)- Flash bytes: Avr2
918 (806), Avr25834 (724), Avr4792 (792) - Stack bytes: Avr2
22, Avr2522, Avr428 - MCU clocks: Avr2
956, Avr25891, Avr4794
- Flash bytes: Avr2
π Math functions π
This 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. the Avr4 girlies are thriving fr fr π₯
__addsf3 (1.234, 5.678)β Avr2113, Avr4108__mulsf3 (1.234, 5.678)β Avr2375, Avr4138__divsf3 (1.234, 5.678)β Avr2466, Avr4465acos (0.54321)β Avr24411, Avr42455asin (0.54321)β Avr24517, Avr42556atan (0.54321)β Avr24710, Avr42271atan2 (1.234, 5.678)β Avr25270, Avr42857cbrt (1.2345)β Avr22684, Avr42555ceil (1.2345)β Avr2177, Avr4177cos (1.2345)β Avr23387, Avr41671cosh (1.2345)β Avr24922, Avr42979exp (1.2345)β Avr24708, Avr42765fdim (5.678, 1.234)β Avr2111, Avr4111floor (1.2345)β Avr2180, Avr4180fmax (1.234, 5.678)β Avr239, Avr437fmin (1.234, 5.678)β Avr235, Avr435fmod (5.678, 1.234)β Avr2131, Avr4131frexp (1.2345, 0)β Avr242, Avr441hypot (1.234, 5.678)β Avr21341, Avr4866ldexp (1.2345, 6)β Avr242, Avr442log (1.2345)β Avr24142, Avr42134log10 (1.2345)β Avr24498, Avr42260modf (1.2345, 0)β Avr2433, Avr4429pow (1.234, 5.678)β Avr29293, Avr45047round (1.2345)β Avr2150, Avr4150sin (1.2345)β Avr23353, Avr41653sinh (1.2345)β Avr24946, Avr43003sqrt (1.2345)β Avr2494, Avr4492tan (1.2345)β Avr24381, Avr42426tanh (1.2345)β Avr25126, Avr43173trunc (1.2345)β Avr2178, Avr4178
heads up bestie: these are rough estimates only. don't come for me when your compiler version eats your flash. π
that's the whole page, we ate and left no crumbs π«Ά this is benchmarks(3avr) from the AVR-LibC Version 2.2.1 manual β that's the version stamped on the page, and yes, that's the exact footer vibe too. mwah, go benchmark responsibly πβ
π¦ where this page comes from
- ubuntu resolute: avr-libc 1:2.2.1-1build1 Β· BSD-3-Clause
- ubuntu stonking: avr-libc 1:2.2.1-1build1 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms