Skip to content

Commit

Permalink
bench: better output
Browse files Browse the repository at this point in the history
  • Loading branch information
kassane committed May 20, 2024
1 parent 7917e17 commit c677f02
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions bench/bench.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <chrono>
#include <random>
#include <vector>
#include <iomanip>
#include <sieve.hpp>

struct S {
Expand Down Expand Up @@ -31,8 +32,8 @@ int main() {
}

auto end = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed_seconds = end - start;
std::cout << "Sequence: " << elapsed_seconds.count() << "s\n";
std::chrono::duration<double, std::micro> elapsed_seconds = end - start;
std::cout << "Sequence: " << std::fixed << std::setprecision(3) << elapsed_seconds.count() << "us\n";

// Composite.
{
Expand All @@ -53,7 +54,7 @@ int main() {

end = std::chrono::high_resolution_clock::now();
elapsed_seconds = end - start;
std::cout << "Composite: " << elapsed_seconds.count() << "s\n";
std::cout << "Composite: " << std::fixed << std::setprecision(3) << elapsed_seconds.count() << "us\n";

// CompositeNormal.
{
Expand All @@ -75,7 +76,7 @@ int main() {

end = std::chrono::high_resolution_clock::now();
elapsed_seconds = end - start;
std::cout << "CompositeNormal: " << elapsed_seconds.count() << "s\n";
std::cout << "Composite Normal: " << std::fixed << std::setprecision(3) << elapsed_seconds.count() << "us\n";

return 0;
}

0 comments on commit c677f02

Please sign in to comment.