aboutsummaryrefslogtreecommitdiffstats
path: root/doc/examples/bench.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2010-01-21 16:36:12 +0000
committerlloyd <[email protected]>2010-01-21 16:36:12 +0000
commit412a13fc607a57bd9986155d247353ba8e5fb203 (patch)
treecbdf63aaa7e9f28a748dedda286e79a138573f74 /doc/examples/bench.cpp
parent41bed2fa0c4d96faf805cd33850166972dcac114 (diff)
parent9b82bb5a720f32e3e7878550310b1151cac188b8 (diff)
propagate from branch 'net.randombit.botan' (head 12382647ef0a28fcb11c824c77b670cc88a4f721)
to branch 'net.randombit.botan.c++0x' (head b586a3286d2c4d547ad3add5af9df1455bf4b87b)
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 87a537493..724c258e4 100644
--- a/doc/examples/bench.cpp
+++ b/doc/examples/bench.cpp
@@ -66,39 +66,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";
}
}