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

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

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