revert benchmarked function specific limit of number of runs changes, as they are not needed

This commit is contained in:
Lin Huang
2023-11-09 17:22:08 -05:00
parent a53e6fc929
commit f54724fb29
2 changed files with 4 additions and 12 deletions
+3 -11
View File
@@ -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();
@@ -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
+1 -1
View File
@@ -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