aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/bench.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-12-21 13:53:40 +0000
committerlloyd <[email protected]>2009-12-21 13:53:40 +0000
commit93e8fd697d009dfef3b994a77936cbf88d2d2ba3 (patch)
treee31140bd8a9f4de3fa0a4705dce389acf50197a0 /doc/examples/bench.cpp
parent75f32d61c6a78e4e63cfadd084730f20b5896493 (diff)
parent1d595f8976483078c292e365bde3949c9de26332 (diff)
propagate from branch 'net.randombit.botan' (head 14c1d4dc8696d2705a70ec3d2403e01d2ca95265)
to branch 'net.randombit.botan.c++0x' (head c567fa7310ba082a837562092728c4b4b882bf82)
Diffstat (limited to 'doc/examples/bench.cpp')
-rw-r--r--doc/examples/bench.cpp42
1 files changed, 16 insertions, 26 deletions
diff --git a/doc/examples/bench.cpp b/doc/examples/bench.cpp
index 6a15df7c0..7d53e0557 100644
--- a/doc/examples/bench.cpp
+++ b/doc/examples/bench.cpp
@@ -60,39 +60,29 @@ const std::string algos[] = {
"",
};
-void benchmark_algo(const std::string& algo,
- RandomNumberGenerator& rng)
+int main()
{
- u32bit milliseconds = 3000;
- Algorithm_Factory& af = global_state().algorithm_factory();
+ LibraryInitializer init;
- std::map<std::string, double> speeds =
- algorithm_benchmark(algo, milliseconds, rng, af);
+ u32bit milliseconds = 1000;
+ AutoSeeded_RNG rng;
- std::cout << algo << ":";
+ Algorithm_Factory& af = global_state().algorithm_factory();
- for(std::map<std::string, double>::const_iterator i = speeds.begin();
- i != speeds.end(); ++i)
+ for(u32bit i = 0; algos[i] != ""; ++i)
{
- std::cout << " " << i->second << " [" << i->first << "]";
- }
- std::cout << "\n";
- }
+ std::string algo = algos[i];
-int main(int argc, char* argv[])
- {
- LibraryInitializer init;
+ std::map<std::string, double> speeds =
+ algorithm_benchmark(algos[i], milliseconds, rng, af);
- AutoSeeded_RNG rng;
+ std::cout << algo << ":";
- 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);
+ for(std::map<std::string, double>::const_iterator i = speeds.begin();
+ i != speeds.end(); ++i)
+ {
+ std::cout << " " << i->second << " [" << i->first << "]";
+ }
+ std::cout << "\n";
}
}