Skip to content

Commit

Permalink
use a single eosio::benchmark for BLS while still being a friend of e…
Browse files Browse the repository at this point in the history
…osio::chain::transaction_context
linh2931 committed Nov 9, 2023
1 parent 181d242 commit 4b65a4f
Showing 10 changed files with 16 additions and 19 deletions.
2 changes: 1 addition & 1 deletion benchmark/alt_bn_128.cpp
Original file line number Diff line number Diff line change
@@ -4,7 +4,7 @@

#include <benchmark.hpp>

namespace benchmark {
namespace eosio::benchmark {

using bytes = std::vector<char>;
using g1g2_pair = std::vector<std::string>;
2 changes: 1 addition & 1 deletion benchmark/benchmark.cpp
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion benchmark/benchmark.hpp
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@

#include <fc/crypto/hex.hpp>

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

void set_num_runs(uint32_t runs);
2 changes: 1 addition & 1 deletion benchmark/blake2.cpp
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@

#include <benchmark.hpp>

namespace benchmark {
namespace eosio::benchmark {

void blake2_benchmarking() {
uint32_t _rounds = 0x0C;
9 changes: 1 addition & 8 deletions benchmark/bls.cpp
Original file line number Diff line number Diff line change
@@ -15,10 +15,7 @@ using namespace bls12_381;
// to run a benchmarking session, in the build directory, type
// benchmark/benchmark -f bls

namespace eosio::chain {
// placed in eosio::chain name space so that interface_in_benchmark
// can access transaction_context's private member max_transaction_time_subjective.
// interface_in_benchmark is a friend of transaction_context.
namespace eosio::benchmark {

// To benchmark host functions directly without CDT wrappers,
// we need to contruct a eosio::chain::webassembly::interface object,
@@ -96,10 +93,6 @@ struct interface_in_benchmark {
std::unique_ptr<apply_context> apply_ctx;
std::unique_ptr<webassembly::interface> interface;
};
} // namespace eosio::chain


namespace benchmark {

// utilility to create a random scalar
std::array<uint64_t, 4> random_scalar()
2 changes: 1 addition & 1 deletion benchmark/hash.cpp
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@

using namespace fc;

namespace benchmark {
namespace eosio::benchmark {

void hash_benchmarking() {
std::string small_message = "abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ01";
2 changes: 1 addition & 1 deletion benchmark/key.cpp
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ using namespace fc::crypto;
using namespace fc;
using namespace std::literals;

namespace benchmark {
namespace eosio::benchmark {

void k1_sign_benchmarking() {
auto payload = "Test Cases";
6 changes: 3 additions & 3 deletions benchmark/main.cpp
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@ int main(int argc, char* argv[]) {
uint32_t num_runs = 1;
std::string feature_name;

auto features = benchmark::get_features();
auto features = eosio::benchmark::get_features();

options_description cli ("benchmark command line options");
cli.add_options()
@@ -61,8 +61,8 @@ int main(int argc, char* argv[]) {
std::cerr << "unknown exception" << std::endl;
}

benchmark::set_num_runs(num_runs);
benchmark::print_header();
eosio::benchmark::set_num_runs(num_runs);
eosio::benchmark::print_header();

if (feature_name.empty()) {
for (auto& [name, f]: features) {
2 changes: 1 addition & 1 deletion benchmark/modexp.cpp
Original file line number Diff line number Diff line change
@@ -5,7 +5,7 @@

#include <benchmark.hpp>

namespace benchmark {
namespace eosio::benchmark {

void modexp_benchmarking() {
std::mt19937 r(0x11223344);
6 changes: 5 additions & 1 deletion libraries/chain/include/eosio/chain/transaction_context.hpp
Original file line number Diff line number Diff line change
@@ -4,6 +4,10 @@
#include <eosio/chain/platform_timer.hpp>
#include <signal.h>

namespace eosio::benchmark {
struct interface_in_benchmark; // for benchmark testing
}

namespace eosio { namespace chain {

struct transaction_checktime_timer {
@@ -92,7 +96,7 @@ namespace eosio { namespace chain {

friend struct controller_impl;
friend class apply_context;
friend struct interface_in_benchmark; // defined in benchmark/bls.cpp
friend struct benchmark::interface_in_benchmark; // defined in benchmark/bls.cpp

void add_ram_usage( account_name account, int64_t ram_delta );

0 comments on commit 4b65a4f

Please sign in to comment.