Skip to content

Commit

Permalink
revert benchmarked function specific limit of number of runs changes,…
Browse files Browse the repository at this point in the history
… as they are not needed
  • Loading branch information
linh2931 committed Nov 9, 2023
1 parent a53e6fc commit f54724f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
14 changes: 3 additions & 11 deletions benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,12 @@ bytes to_bytes(const std::string& source) {
return output;
};

void benchmarking(const std::string& name,
const std::function<void()>& func,
uint32_t max_num_runs) {

void benchmarking(const std::string& name, const std::function<void()>& func) {
uint64_t total{0};
uint64_t min{std::numeric_limits<uint64_t>::max()};
uint64_t max{0};

// some benchmarked functions are expensive and run in a transaction
// (like BLS pairing). Limit actual number of runs to the function
// specific maximum such that transaction deadline is not exceeded.
uint32_t actual_num_runs = (num_runs > max_num_runs) ? max_num_runs : num_runs;

for (auto i = 0U; i < actual_num_runs; ++i) {
for (auto i = 0U; i < num_runs; ++i) {
auto start_time = std::chrono::high_resolution_clock::now();
func();
auto end_time = std::chrono::high_resolution_clock::now();
Expand All @@ -87,7 +79,7 @@ void benchmarking(const std::string& name,
max = std::max(max, duration);
}

print_results(name, actual_num_runs, total, min, max);
print_results(name, num_runs, total, min, max);
}

} // benchmark
2 changes: 1 addition & 1 deletion benchmark/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,6 @@ void hash_benchmarking();
void blake2_benchmarking();
void bls_benchmarking();

void benchmarking(const std::string& name, const std::function<void()>& func, uint32_t max_num_runs = std::numeric_limits<uint32_t>::max());
void benchmarking(const std::string& name, const std::function<void()>& func);

} // benchmark

0 comments on commit f54724f

Please sign in to comment.