Skip to content

Commit

Permalink
Prettier outputs for benchmarks
Browse files Browse the repository at this point in the history
  • Loading branch information
sachaservan committed Nov 23, 2024
1 parent 40b56f0 commit aa4916c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 12 deletions.
9 changes: 6 additions & 3 deletions bcmpr-bipsw/src/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ double benchmarkOTs()
t = clock() - t;
double time_taken = ((double)t) / (CLOCKS_PER_SEC / 1000.0); // ms

printf("Time (total) %f ms\n", time_taken);
printf("Took %.2f ms to generate %zu OTs\n", time_taken, num_ots);

if (!receiver_eval(
pp,
Expand Down Expand Up @@ -154,7 +154,10 @@ int main(int argc, char **argv)
for (int i = 0; i < testTrials; i++)
avg += benchmarkOTs();
printf("******************************************\n");
printf("PASS\n");
printf("Avg time: %f\n", avg / testTrials);
avg = avg / testTrials;
printf("SUMMARY\n");
printf("Avg. time: %.2f ms to generate %llu OTs\n", avg, (long long unsigned int)NUM_OTS);
printf("Performance: %i OTs/sec\n", (int)(((double)(NUM_OTS) / avg) * 1000)); // Convert ms to seconds
printf("Number of trials: %i\n", testTrials);
printf("******************************************\n\n");
}
19 changes: 13 additions & 6 deletions other/src/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ double benchmark_BCMPR_GAR()
t = clock() - t;

double time_taken = ((double)t) / (CLOCKS_PER_SEC / 1000.0); // ms
printf("Time (total) %f ms\n", time_taken);
printf("Took %.2f ms to generate %llu OTs\n", time_taken, (long long unsigned int)NUM_OTS);

free_master_key(pp, msk0);
free_master_key(pp, msk1);
Expand Down Expand Up @@ -179,7 +179,7 @@ double benchmark_OSY()
free(exps);
}

printf("Time (total) %f ms\n", time_taken / num_trials_internal);
printf("Took %.2f ms to generate one OT\n", time_taken / num_trials_internal);

// free up memory
BN_CTX_free(ctx);
Expand All @@ -196,8 +196,11 @@ int main(int argc, char **argv)
for (int i = 0; i < testTrials; i++)
avg += benchmark_BCMPR_GAR();
printf("******************************************\n");
printf("PASS\n");
printf("Avg time: %f\n", avg / testTrials);
avg = avg / testTrials;
printf("SUMMARY\n");
printf("Avg. time: %.2f ms to generate %llu OTs\n", avg, (long long unsigned int)NUM_OTS);
printf("Performance: %i OTs/sec\n", (int)(((int)(NUM_OTS)) * (1000.0 / avg))); // Convert ms to seconds
printf("Number of trials: %i\n", testTrials);
printf("******************************************\n\n");

avg = 0;
Expand All @@ -206,7 +209,11 @@ int main(int argc, char **argv)
for (int i = 0; i < testTrials; i++)
avg += benchmark_OSY();
printf("******************************************\n");
printf("PASS\n");
printf("Avg time: %f\n", avg / testTrials);
avg = avg / testTrials;
printf("SUMMARY\n");
printf("Avg. time: %.2f ms to generate %llu OTs\n", avg, (long long unsigned int)NUM_OTS);
// Note: OSY is a single OT
printf("Performance: %.2f OTs/sec\n", (1000.0 / avg)); // Convert ms
printf("Number of trials: %i\n", testTrials);
printf("******************************************\n\n");
}
5 changes: 3 additions & 2 deletions quiet-bipsw/src/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,11 @@ int main(int argc, char **argv)
#endif
for (int i = 0; i < testTrials; i++)
avg += benchmarkOTs();
printf("******************************************\n");
avg = avg / testTrials;
printf("******************************************\n\n");
printf("SUMMARY\n");
printf("Avg. time: %.2f ms to generate %llu OTs\n", avg, (long long unsigned int)NUM_OTS);
printf("Performance: %.2f OTs/sec\n", ((double)(NUM_OTS) / avg) * 1000); // Convert ms to seconds
printf("Performance: %i OTs/sec\n", (int)(((double)(NUM_OTS) / avg) * 1000)); // Convert ms to seconds
printf("Number of trials: %i\n", testTrials);
printf("******************************************\n\n");
}
2 changes: 1 addition & 1 deletion quiet-gar/src/test.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ int main(int argc, char **argv)
printf("******************************************\n");
printf("SUMMARY\n");
printf("Avg. time: %.2f ms to generate %llu OTs\n", avg, (long long unsigned int)NUM_OTS);
printf("Performance: %.2f OTs/sec\n", ((double)(NUM_OTS) / avg) * 1000); // Convert ms to seconds
printf("Performance: %i OTs/sec\n", (int)(((double)(NUM_OTS) / avg) * 1000)); // Convert ms to seconds
printf("Number of trials: %i\n", testTrials);
printf("******************************************\n\n");
}

0 comments on commit aa4916c

Please sign in to comment.