Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release/5.0' into GH-1461-base64…
Browse files Browse the repository at this point in the history
…-main
  • Loading branch information
heifner committed Nov 14, 2023
2 parents ea18a6d + f1919a0 commit 1b8e184
Show file tree
Hide file tree
Showing 11 changed files with 447 additions and 15 deletions.
3 changes: 2 additions & 1 deletion benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
file(GLOB BENCHMARK "*.cpp")
add_executable( benchmark ${BENCHMARK} )

target_link_libraries( benchmark fc Boost::program_options bn256)
target_link_libraries( benchmark eosio_testing fc Boost::program_options bn256)
target_include_directories( benchmark PUBLIC
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}/../unittests/include"
)
2 changes: 1 addition & 1 deletion benchmark/alt_bn_128.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <benchmark.hpp>

namespace benchmark {
namespace eosio::benchmark {

using bytes = std::vector<char>;
using g1g2_pair = std::vector<std::string>;
Expand Down
11 changes: 7 additions & 4 deletions benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <benchmark.hpp>

namespace benchmark {
namespace eosio::benchmark {

// update this map when a new feature is supported
// key is the name and value is the function doing benchmarking
Expand All @@ -15,6 +15,7 @@ std::map<std::string, std::function<void()>> features {
{ "key", key_benchmarking },
{ "hash", hash_benchmarking },
{ "blake2", blake2_benchmarking },
{ "bls", bls_benchmarking }
};

// values to control cout format
Expand Down Expand Up @@ -46,10 +47,10 @@ void print_results(std::string name, uint32_t runs, uint64_t total, uint64_t min
std::cout.imbue(std::locale(""));
std::cout
<< std::setw(name_width) << std::left << name
<< std::setw(runs_width) << runs
// std::fixed for not printing 1234 in 1.234e3.
// setprecision(0) for not printing fractions
<< std::right << std::fixed << std::setprecision(0)
<< std::setw(runs_width) << runs
<< std::setw(time_width) << total/runs << std::setw(ns_width) << " ns"
<< std::setw(time_width) << min << std::setw(ns_width) << " ns"
<< std::setw(time_width) << max << std::setw(ns_width) << " ns"
Expand All @@ -62,8 +63,10 @@ bytes to_bytes(const std::string& source) {
return output;
};

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

for (auto i = 0U; i < num_runs; ++i) {
auto start_time = std::chrono::high_resolution_clock::now();
Expand Down
6 changes: 4 additions & 2 deletions benchmark/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@
#include <functional>
#include <map>
#include <vector>
#include <limits>

#include <fc/crypto/hex.hpp>

namespace benchmark {
namespace eosio::benchmark {
using bytes = std::vector<char>;

void set_num_runs(uint32_t runs);
Expand All @@ -19,7 +20,8 @@ void modexp_benchmarking();
void key_benchmarking();
void hash_benchmarking();
void blake2_benchmarking();
void bls_benchmarking();

void benchmarking(std::string name, const std::function<void()>& func);
void benchmarking(const std::string& name, const std::function<void()>& func);

} // benchmark
2 changes: 1 addition & 1 deletion benchmark/blake2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

#include <benchmark.hpp>

namespace benchmark {
namespace eosio::benchmark {

void blake2_benchmarking() {
uint32_t _rounds = 0x0C;
Expand Down
Loading

0 comments on commit 1b8e184

Please sign in to comment.