Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Trivial BlockId::Number => Hash #12490

Merged
merged 1 commit into from
Oct 13, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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