Skip to content

Commit

Permalink
Trivial BlockId::Number => Hash (paritytech#12490)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkucharczyk authored and ark0f committed Feb 27, 2023
1 parent 09f29fc commit eb08976
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions primitives/api/test/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,30 +27,30 @@ fn sp_api_benchmark(c: &mut Criterion) {
c.bench_function("add one with same runtime api", |b| {
let client = substrate_test_runtime_client::new();
let runtime_api = client.runtime_api();
let block_id = BlockId::Number(client.chain_info().best_number);
let block_id = BlockId::Hash(client.chain_info().best_hash);

b.iter(|| runtime_api.benchmark_add_one(&block_id, &1))
});

c.bench_function("add one with recreating runtime api", |b| {
let client = substrate_test_runtime_client::new();
let block_id = BlockId::Number(client.chain_info().best_number);
let block_id = BlockId::Hash(client.chain_info().best_hash);

b.iter(|| client.runtime_api().benchmark_add_one(&block_id, &1))
});

c.bench_function("vector add one with same runtime api", |b| {
let client = substrate_test_runtime_client::new();
let runtime_api = client.runtime_api();
let block_id = BlockId::Number(client.chain_info().best_number);
let block_id = BlockId::Hash(client.chain_info().best_hash);
let data = vec![0; 1000];

b.iter_with_large_drop(|| runtime_api.benchmark_vector_add_one(&block_id, &data))
});

c.bench_function("vector add one with recreating runtime api", |b| {
let client = substrate_test_runtime_client::new();
let block_id = BlockId::Number(client.chain_info().best_number);
let block_id = BlockId::Hash(client.chain_info().best_hash);
let data = vec![0; 1000];

b.iter_with_large_drop(|| client.runtime_api().benchmark_vector_add_one(&block_id, &data))
Expand All @@ -60,15 +60,15 @@ fn sp_api_benchmark(c: &mut Criterion) {
let client = TestClientBuilder::new()
.set_execution_strategy(ExecutionStrategy::AlwaysWasm)
.build();
let block_id = BlockId::Number(client.chain_info().best_number);
let block_id = BlockId::Hash(client.chain_info().best_hash);
b.iter(|| client.runtime_api().benchmark_indirect_call(&block_id).unwrap())
});

c.bench_function("calling function in wasm", |b| {
let client = TestClientBuilder::new()
.set_execution_strategy(ExecutionStrategy::AlwaysWasm)
.build();
let block_id = BlockId::Number(client.chain_info().best_number);
let block_id = BlockId::Hash(client.chain_info().best_hash);
b.iter(|| client.runtime_api().benchmark_direct_call(&block_id).unwrap())
});
}
Expand Down

0 comments on commit eb08976

Please sign in to comment.