aboutsummaryrefslogtreecommitdiffstats
path: root/checks
diff options
context:
space:
mode:
authorlloyd <[email protected]>2006-09-27 03:44:57 +0000
committerlloyd <[email protected]>2006-09-27 03:44:57 +0000
commit15da8dc78bb8fa5e5cabf90295a55e7421a1f1dc (patch)
treeea33908012bdda6139f67e0b5b6d33da6bd4966b /checks
parentb81d5af9768c47b7eb9de8032b4603af30e623f5 (diff)
Add (very basic) HTML output for public key benchmarking.
Diffstat (limited to 'checks')
-rw-r--r--checks/check.cpp6
-rw-r--r--checks/pk_bench.cpp37
2 files changed, 29 insertions, 14 deletions
diff --git a/checks/check.cpp b/checks/check.cpp
index 577e469c5..ac4e75fa3 100644
--- a/checks/check.cpp
+++ b/checks/check.cpp
@@ -59,6 +59,8 @@ int main(int argc, char* argv[])
}
}
+ const bool html = opts.is_set("html");
+
if(opts.is_set("bench-algo"))
{
std::vector<std::string> algs =
@@ -69,12 +71,10 @@ int main(int argc, char* argv[])
const std::string alg = algs[j];
u32bit found = bench_algo(alg, seconds);
if(!found) // maybe it's a PK algorithm
- bench_pk(alg, false, seconds);
+ bench_pk(alg, html, seconds);
}
}
- const bool html = opts.is_set("html");
-
if(opts.is_set("benchmark"))
benchmark("All", html, seconds);
else if(opts.is_set("bench-type"))
diff --git a/checks/pk_bench.cpp b/checks/pk_bench.cpp
index e2b6877eb..875485944 100644
--- a/checks/pk_bench.cpp
+++ b/checks/pk_bench.cpp
@@ -252,24 +252,39 @@ void bench_pk(const std::string& algo, bool html, double seconds)
}
-void print_result(bool, u32bit runs, u64bit clocks_used,
+void print_result(bool html, u32bit runs, u64bit clocks_used,
const std::string& algo_name, const std::string& op)
{
- std::cout << algo_name << ": ";
-
double seconds = (double)clocks_used / get_ticks();
- std::cout.setf(std::ios::fixed, std::ios::floatfield);
- std::cout.precision(2);
+ double mseconds_per_run = 1000 * (seconds / runs);
+ double runs_per_sec = runs / seconds;
+
+
+ if(html)
+ {
+ std::cout << " <TR><TH>" << algo_name << " (" << op << ") <TH>";
#if PRINT_MS_PER_OP
- // print milliseconds / op
- double mseconds_per_run = 1000 * (seconds / runs);
- std::cout << mseconds_per_run << " ms / " << op << std::endl;
+ std::cout << mseconds_per_run;
#else
- // print ops / second
- double runs_per_sec = runs / seconds;
- std::cout << runs_per_sec << " ops / second (" << op << ")" << std::endl;
+ std::cout << runs_per_sec;
#endif
+
+ std::cout << std::endl;
+ }
+ else
+ {
+ std::cout << algo_name << ": ";
+
+ std::cout.setf(std::ios::fixed, std::ios::floatfield);
+ std::cout.precision(2);
+
+#if PRINT_MS_PER_OP
+ std::cout << mseconds_per_run << " ms / " << op << std::endl;
+#else
+ std::cout << runs_per_sec << " ops / second (" << op << ")" << std::endl;
+#endif
+ }
}
void bench_enc(PK_Encryptor* enc, const std::string& algo_name,