Skip to content

Instantly share code, notes, and snippets.

@Au-lit
Last active October 29, 2021 01:39
Show Gist options
  • Save Au-lit/447f376101674503aac2d721fcee0cd1 to your computer and use it in GitHub Desktop.
Save Au-lit/447f376101674503aac2d721fcee0cd1 to your computer and use it in GitHub Desktop.

msvc results:

ns/op op/s err% total Random u32 to base 10. w/ /utf-8
2.71 369,270,304.57 1.4% 0.00 null, i.e. the rng perf
6.98 143,213,409.65 1.6% 0.00 jeaiii::to_text
9.63 103,842,159.92 0.4% 0.01 fmt::format_int
21.46 46,606,363.07 2.0% 0.01 std::to_string
21.56 46,372,782.63 1.1% 0.01 std::to_chars
54.56 18,329,649.17 1.0% 0.03 std::sprintf
576.23 1,735,415.94 0.8% 0.35 std::ostringstream
481.76 2,075,704.25 0.7% 0.29 std::ostrstream
39.96 25,027,285.13 1.5% 0.02 fmt::format
17.18 58,199,071.27 1.4% 0.01 fmt::format - FMT_COMPILE
20.13 49,683,860.23 1.1% 0.01 fmt::format_to
10.64 93,941,234.41 1.6% 0.01 fmt::format_to - FMT_COMPILE
7.99 125,156,445.56 0.3% 0.00 fast_io::print_reserve_define
10.33 96,843,891.40 0.6% 0.01 fast_io::concat
90.93 10,997,356.26 0.6% 0.06 std::format
51.58 19,387,174.36 0.3% 0.03 std::format_to

Clang-cl results:

ns/op op/s err% total Random u32 to base 10. w/ /utf-8
2.46 407,325,581.40 0.0% 0.00 null, i.e. the rng perf
5.73 174,570,458.40 0.2% 0.00 jeaiii::to_text
9.66 103,548,163.55 0.5% 0.01 fmt::format_int
17.55 56,978,369.38 0.4% 0.01 std::to_string
14.33 69,767,329.13 0.5% 0.01 std::to_chars
54.00 18,518,714.32 1.0% 0.03 std::sprintf
558.16 1,791,589.81 2.2% 0.34 std::ostringstream
475.49 2,103,103.93 1.4% 0.29 std::ostrstream
29.76 33,597,568.95 2.8% 0.02 fmt::format
15.27 65,500,063.70 3.0% 0.01 fmt::format - FMT_COMPILE
17.48 57,196,068.80 0.6% 0.01 fmt::format_to
8.59 116,348,557.15 1.1% 0.01 fmt::format_to - FMT_COMPILE
5.83 171,609,195.40 0.6% 0.00 fast_io::print_reserve_define
9.30 107,517,503.50 0.3% 0.01 fast_io::concat

Notes:

  • When a function returns an std::string, I copy [result.begin(), result.end()] to an other buffer to emulate string assignement.
  • this was ran on a ryzen 3700x if that helps you for stuff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment