Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Benchmark for strtod

  • Loading branch information...
commit 6027987316f0a7308fd286f1e8e1341e091bbbe4 1 parent a8af35d
Fuji Goro authored
Showing with 23 additions and 2 deletions.
  1. +3 −2 Makefile
  2. +20 −0 benchmark.cpp
View
5 Makefile
@@ -1,11 +1,12 @@
+
test: fast_strtox.h test.cpp
- g++ -O3 test.cpp -o test
+ g++ -O3 $(CFLAGS) test.cpp -o test
./test
benchmark: fast_strtox.h benchmark.cpp
g++ -O3 benchmark.cpp -o benchmark
./benchmark
- clang++ -O3 benchmark.cpp -o benchmark
+ clang++ -O3 $(CFLAGS) benchmark.cpp -o benchmark
./benchmark
View
20 benchmark.cpp
@@ -29,6 +29,26 @@ int main() {
}
std::cout << "fast_strtof(): " << t.elapsed() << std::endl;
}
+
+ {
+ boost::timer t;
+ for(int i = 0; i < (1 * 1000 * 1000); ++i) {
+ char* tmp;
+ double f = std::strtod(pistr, &tmp);
+ (void)f;
+ }
+ std::cout << "std::strtod(): " << t.elapsed() << std::endl;
+ }
+ {
+ boost::timer t;
+ for(int i = 0; i < (1 * 1000 * 1000); ++i) {
+ char* tmp;
+ double f = fast_strtod(pistr, &tmp);
+ (void)f;
+ }
+ std::cout << "fast_strtod(): " << t.elapsed() << std::endl;
+ }
+
{
boost::timer t;
for(int i = 0; i < (1 * 1000 * 1000); ++i) {
Please sign in to comment.
Something went wrong with that request. Please try again.