paint-brush
Why Math Functions in C++ Are So Slowby@ryanburn
1,413 reads
1,413 reads

Why Math Functions in C++ Are So Slow

by Ryan Burn5mDecember 27th, 2020
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

Compilers produce code that is significantly slower than what a machine is capable of. Compilers may not be portable even between different x86-64 CPUs. Compiler will optimize the code heavily but will still produce C++ standard compliant code. Compiling the code with C++ -c -O3 -march=native, we get a benchmark benchmark. We’ll use google benchmark to measure how long it takes to compute the square roots of 1,000,000 numbers. Compile with GCC -c:native:compute_sqrt1/1000000 4984457 (4.17, 0.07, 115.05)

Companies Mentioned

Mention Thumbnail
Mention Thumbnail
featured image - Why Math Functions in C++ Are So Slow
Ryan Burn HackerNoon profile picture
Ryan Burn

Ryan Burn

@ryanburn

Mathematical Engineer | Building better models: buildingblock.ai

About @ryanburn
LEARN MORE ABOUT @RYANBURN'S
EXPERTISE AND PLACE ON THE INTERNET.
L O A D I N G
. . . comments & more!

About Author

Ryan Burn HackerNoon profile picture
Ryan Burn@ryanburn
Mathematical Engineer | Building better models: buildingblock.ai

TOPICS

THIS ARTICLE WAS FEATURED IN...

Permanent on Arweave
Read on Terminal Reader
Read this story in a terminal
 Terminal
Read this story w/o Javascript
Read this story w/o Javascript
 Lite