/mobile Handheld Friendly website
x64 Ubuntu : Intel® Q6600® one core |
Each table row shows performance measurements for this C++ g++ program with a particular command-line input value N.
| N | CPU secs | Elapsed secs | Memory KB | Code B | ≈ CPU Load |
|---|---|---|---|---|---|
| 12 | 0.07 | 0.08 | ? | 553 | 0% 0% 0% 100% |
| 16 | 1.72 | 1.72 | 13,480 | 553 | 0% 0% 2% 100% |
| 20 | 37.60 | 37.63 | 197,756 | 553 | 0% 0% 0% 100% |
Read the ↓ make, command line, and program output logs to see how this program was run.
Read binary-trees benchmark to see what this program should do.
gcc (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3
/* The Computer Language Benchmarks Game * http://benchmarksgame.alioth.debian.org/ * * Contributed by Jon Harrop * Modified by Alex Mizrahi */ #include <stdio.h> #include <stdlib.h> #include <iostream> struct Node { Node *l, *r; int i; Node(int i2) : l(0), r(0), i(i2) {} Node(Node *l2, int i2, Node *r2) : l(l2), r(r2), i(i2) {} ~Node() { delete l; delete r; } int check() const { if (l) return l->check() + i - r->check(); else return i; } }; Node *make(int i, int d) { if (d == 0) return new Node(i); return new Node(make(2*i-1, d-1), i, make(2*i, d-1)); } int main(int argc, char *argv[]) { int min_depth = 4, max_depth = std::max(min_depth+2, (argc == 2 ? atoi(argv[1]) : 10)), stretch_depth = max_depth+1; { Node *c = make(0, stretch_depth); std::cout << "stretch tree of depth " << stretch_depth << "\t " << "check: " << c->check() << std::endl; delete c; } Node *long_lived_tree=make(0, max_depth); for (int d=min_depth; d<=max_depth; d+=2) { int iterations = 1 << (max_depth - d + min_depth), c=0; for (int i=1; i<=iterations; ++i) { Node *a = make(i, d), *b = make(-i, d); c += a->check() + b->check(); delete a; delete b; } std::cout << (2*iterations) << "\t trees of depth " << d << "\t " << "check: " << c << std::endl; } std::cout << "long lived tree of depth " << max_depth << "\t " << "check: " << (long_lived_tree->check()) << "\n"; delete long_lived_tree; return 0; }
Mon, 29 Apr 2013 19:37:08 GMT
MAKE:
/usr/bin/g++ -c -pipe -O3 -fomit-frame-pointer -march=native -fopenmp binarytrees.gpp-2.c++ -o binarytrees.gpp-2.c++.o && \
/usr/bin/g++ binarytrees.gpp-2.c++.o -o binarytrees.gpp-2.gpp_run -fopenmp
rm binarytrees.gpp-2.c++
0.46s to complete and log all make actions
COMMAND LINE:
./binarytrees.gpp-2.gpp_run 20
PROGRAM OUTPUT:
stretch tree of depth 21 check: -1
2097152 trees of depth 4 check: -2097152
524288 trees of depth 6 check: -524288
131072 trees of depth 8 check: -131072
32768 trees of depth 10 check: -32768
8192 trees of depth 12 check: -8192
2048 trees of depth 14 check: -2048
512 trees of depth 16 check: -512
128 trees of depth 18 check: -128
32 trees of depth 20 check: -32
long lived tree of depth 20 check: -1