diff options
author | lloyd <[email protected]> | 2009-08-14 16:21:26 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2009-08-14 16:21:26 +0000 |
commit | 6ad564671027ca5caa842592ab6708003b5893ef (patch) | |
tree | 7aaff8fc85ae3f3f4f38e5bd2d2fdc7e25b55ba3 /checks | |
parent | 1c08f8e0258d1b0317fb837e78b4cef9359af9c9 (diff) |
Remove support for HTML benchmark output. Easier/simpler to parse the
output with a script after the fact to generate such things, especially
as often for HTML I want to do multiple side-by-side results.
Diffstat (limited to 'checks')
-rw-r--r-- | checks/bench.cpp | 56 | ||||
-rw-r--r-- | checks/bench.h | 4 | ||||
-rw-r--r-- | checks/check.cpp | 25 | ||||
-rw-r--r-- | checks/pk_bench.cpp | 2 |
4 files changed, 24 insertions, 63 deletions
diff --git a/checks/bench.cpp b/checks/bench.cpp index 6df7319c0..1610bed1e 100644 --- a/checks/bench.cpp +++ b/checks/bench.cpp @@ -27,7 +27,7 @@ namespace { double bench_filter(std::string name, Botan::Filter* filter, Botan::RandomNumberGenerator& rng, - bool html, double seconds) + double seconds) { Botan::Pipe pipe(filter, new BitBucket); @@ -52,27 +52,13 @@ double bench_filter(std::string name, Botan::Filter* filter, std::cout.setf(std::ios::fixed, std::ios::floatfield); std::cout.precision(2); - if(html) - { - if(name.find("<") != std::string::npos) - name.replace(name.find("<"), 1, "<"); - if(name.find(">") != std::string::npos) - name.replace(name.find(">"), 1, ">"); - std::cout << " <TR><TH>" << name - << std::string(25 - name.length(), ' ') << " <TH>"; - std::cout.width(6); - std::cout << mbytes_per_sec << std::endl; - } - else - { - std::cout << name << ": " << std::string(25 - name.length(), ' '); - std::cout.width(6); - std::cout << mbytes_per_sec << " MiB/sec" << std::endl; - } + std::cout << name << " " << std::string(25 - name.length(), ' '); + std::cout.width(6); + std::cout << mbytes_per_sec << " MiB/sec" << std::endl; return (mbytes_per_sec); } -double bench(const std::string& name, const std::string& filtername, bool html, +double bench(const std::string& name, const std::string& filtername, double seconds, u32bit keylen, u32bit ivlen, Botan::RandomNumberGenerator& rng) { @@ -88,7 +74,7 @@ double bench(const std::string& name, const std::string& filtername, bool html, Botan::Filter* filter = lookup(filtername, params); if(filter) - return bench_filter(name, filter, rng, html, seconds); + return bench_filter(name, filter, rng, seconds); return 0; } @@ -96,23 +82,9 @@ double bench(const std::string& name, const std::string& filtername, bool html, void benchmark(const std::string& what, Botan::RandomNumberGenerator& rng, - bool html, double seconds) + double seconds) { try { - if(html) - { - std::cout << "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD " - << "HTML 4.0 Transitional//EN\">\n" - << "<HTML>\n\n" - << "<TITLE>Botan Benchmarks</TITLE>\n\n" - << "<BODY>\n\n" - << "<P><TABLE BORDER CELLSPACING=1>\n" - << "<THEAD>\n" - << "<TR><TH>Algorithm " - << "<TH>Mib / second\n" - << "<TBODY>\n"; - } - double sum = 0; u32bit how_many = 0; @@ -122,26 +94,18 @@ void benchmark(const std::string& what, if(what == "All" || what == algos[j].type) { double speed = bench(algos[j].name, algos[j].filtername, - html, seconds, algos[j].keylen, + seconds, algos[j].keylen, algos[j].ivlen, rng); if(speed > .00001) /* log(0) == -inf -> messed up average */ sum += std::log(speed); how_many++; } - if(html) - std::cout << "</TABLE>\n\n"; - double average = std::exp(sum / static_cast<double>(how_many)); - if(what == "All" && html) - std::cout << "\n<P>Overall speed average: " << average - << "\n\n"; - else if(what == "All") + if(what == "All") std::cout << "\nOverall speed average: " << average << std::endl; - - if(html) std::cout << "</BODY></HTML>\n"; } catch(Botan::Exception& e) { @@ -172,7 +136,7 @@ u32bit bench_algo(const std::string& name, { if(algos[j].name == name) { - bench(algos[j].name, algos[j].filtername, false, seconds, + bench(algos[j].name, algos[j].filtername, seconds, algos[j].keylen, algos[j].ivlen, rng); return 1; } diff --git a/checks/bench.h b/checks/bench.h index 07d67e0d1..0cc3f46d1 100644 --- a/checks/bench.h +++ b/checks/bench.h @@ -25,10 +25,10 @@ class Benchmark_Report void benchmark(const std::string&, Botan::RandomNumberGenerator&, - bool html, double seconds); + double seconds); void bench_pk(Botan::RandomNumberGenerator&, - const std::string&, bool html, double seconds); + const std::string&, double seconds); u32bit bench_algo(const std::string&, Botan::RandomNumberGenerator&, diff --git a/checks/check.cpp b/checks/check.cpp index 678cf4b09..30ee90d98 100644 --- a/checks/check.cpp +++ b/checks/check.cpp @@ -94,7 +94,7 @@ int main(int argc, char* argv[]) { try { - OptionParser opts("help|html|test|validate|" + OptionParser opts("help|test|validate|" "benchmark|bench-type=|bench-algo=|seconds="); opts.parse(argv); @@ -113,7 +113,6 @@ int main(int argc, char* argv[]) << " --benchmark: Benchmark everything\n" << " --bench-type={block,mode,stream,hash,mac,rng,pk}:\n" << " Benchmark only algorithms of a particular type\n" - << " --html: Produce HTML output for benchmarks\n" << " --seconds=n: Benchmark for n seconds\n" << " --init=<str>: Pass <str> to the library\n" << " --help: Print this message\n"; @@ -140,11 +139,9 @@ int main(int argc, char* argv[]) } } - const bool html = opts.is_set("html"); - if(opts.is_set("benchmark")) { - benchmark("All", rng, html, seconds); + benchmark("All", rng, seconds); } else if(opts.is_set("bench-algo")) { @@ -156,7 +153,7 @@ int main(int argc, char* argv[]) const std::string alg = algs[j]; u32bit found = bench_algo(alg, rng, seconds); if(!found) // maybe it's a PK algorithm - bench_pk(rng, alg, html, seconds); + bench_pk(rng, alg, seconds); } } else if(opts.is_set("bench-type")) @@ -164,21 +161,21 @@ int main(int argc, char* argv[]) const std::string type = opts.value("bench-type"); if(type == "all") - benchmark("All", rng, html, seconds); + benchmark("All", rng, seconds); else if(type == "block") - benchmark("Block Cipher", rng, html, seconds); + benchmark("Block Cipher", rng, seconds); else if(type == "stream") - benchmark("Stream Cipher", rng, html, seconds); + benchmark("Stream Cipher", rng, seconds); else if(type == "hash") - benchmark("Hash", rng, html, seconds); + benchmark("Hash", rng, seconds); else if(type == "mode") - benchmark("Cipher Mode", rng, html, seconds); + benchmark("Cipher Mode", rng, seconds); else if(type == "mac") - benchmark("MAC", rng, html, seconds); + benchmark("MAC", rng, seconds); else if(type == "rng") - benchmark("RNG", rng, html, seconds); + benchmark("RNG", rng, seconds); else if(type == "pk") - bench_pk(rng, "All", html, seconds); + bench_pk(rng, "All", seconds); else std::cerr << "Unknown --bench-type " << type << "\n"; } diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp index a944934fb..1b85eddbf 100644 --- a/checks/pk_bench.cpp +++ b/checks/pk_bench.cpp @@ -603,7 +603,7 @@ void benchmark_elg(RandomNumberGenerator& rng, } void bench_pk(RandomNumberGenerator& rng, - const std::string& algo, bool, double seconds) + const std::string& algo, double seconds) { /* There is some strangeness going on here. It looks like algorithms |