aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/bench.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-09-17 14:12:57 +0000
committerlloyd <[email protected]>2009-09-17 14:12:57 +0000
commit7e839d037119055b572f40ce0cd882f85583db2e (patch)
tree03792d0825d846f634cf34341b87e01ef91cb22f /doc/examples/bench.cpp
parente1d81327dde6c6837ed81c61c58876bd261fb47d (diff)
The get_tm function was duplicated. Move single version to timer.{h,cpp}
Diffstat (limited to 'doc/examples/bench.cpp')
-rw-r--r--doc/examples/bench.cpp44
1 files changed, 27 insertions, 17 deletions
diff --git a/doc/examples/bench.cpp b/doc/examples/bench.cpp
index 0aedc699d..cc43fade0 100644
--- a/doc/examples/bench.cpp
+++ b/doc/examples/bench.cpp
@@ -60,30 +60,40 @@ const std::string algos[] = {
"",
};
-int main()
+void benchmark_algo(const std::string& algo,
+ RandomNumberGenerator& rng)
{
- LibraryInitializer init;
-
- u32bit milliseconds = 1000;
- AutoSeeded_RNG rng;
+ u32bit milliseconds = 3000;
Default_Benchmark_Timer timer;
-
Algorithm_Factory& af = global_state().algorithm_factory();
- for(u32bit i = 0; algos[i] != ""; ++i)
+ std::map<std::string, double> speeds =
+ algorithm_benchmark(algo, milliseconds, timer, rng, af);
+
+ std::cout << algo << ":";
+
+ for(std::map<std::string, double>::const_iterator i = speeds.begin();
+ i != speeds.end(); ++i)
{
- std::string algo = algos[i];
+ std::cout << " " << i->second << " [" << i->first << "]";
+ }
+ std::cout << "\n";
+ }
- std::map<std::string, double> speeds =
- algorithm_benchmark(algos[i], milliseconds, timer, rng, af);
+int main(int argc, char* argv[])
+ {
+ LibraryInitializer init;
- std::cout << algo << ":";
+ AutoSeeded_RNG rng;
- for(std::map<std::string, double>::const_iterator i = speeds.begin();
- i != speeds.end(); ++i)
- {
- std::cout << " " << i->second << " [" << i->first << "]";
- }
- std::cout << "\n";
+ if(argc == 1) // no args, benchmark everything
+ {
+ for(u32bit i = 0; algos[i] != ""; ++i)
+ benchmark_algo(algos[i], rng);
+ }
+ else
+ {
+ for(int i = 1; argv[i]; ++i)
+ benchmark_algo(argv[i], rng);
}
}