Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
polkadot-sdk
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
parity
Mirrored projects
polkadot-sdk
Commits
e417f986
Commit
e417f986
authored
5 years ago
by
Nikolay Volf
Committed by
GitHub
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
wasm per block size bench (#4982)
parent
a98e6b0e
Branches
gh-readonly-queue/master/pr-5196-efdc1e9b1615c5502ed63ffc9683d99af6397263
Branches containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/bin/node/testing/benches/import.rs
+46
-1
46 additions, 1 deletion
substrate/bin/node/testing/benches/import.rs
with
46 additions
and
1 deletion
substrate/bin/node/testing/benches/import.rs
+
46
−
1
View file @
e417f986
...
...
@@ -28,7 +28,9 @@
//! to much configuring - just block full of randomized transactions.
//! It is not supposed to measure runtime modules weight correctness
use
std
::
fmt
;
use
node_testing
::
bench
::{
BenchDb
,
Profile
};
use
node_primitives
::
Block
;
use
sp_runtime
::
generic
::
BlockId
;
use
criterion
::{
Criterion
,
criterion_group
,
criterion_main
};
use
sc_client_api
::
backend
::
Backend
;
...
...
@@ -38,12 +40,17 @@ criterion_group!(
config
=
Criterion
::
default
()
.sample_size
(
50
)
.warm_up_time
(
std
::
time
::
Duration
::
from_secs
(
20
));
targets
=
bench_block_import
);
criterion_group!
(
name
=
wasm_size
;
config
=
Criterion
::
default
()
.sample_size
(
10
);
targets
=
bench_wasm_size_import
);
criterion_group!
(
name
=
profile
;
config
=
Criterion
::
default
()
.sample_size
(
10
);
targets
=
profile_block_import
);
criterion_main!
(
benches
,
profile
);
criterion_main!
(
benches
,
profile
,
wasm_size
);
fn
bench_block_import
(
c
:
&
mut
Criterion
)
{
sc_cli
::
init_logger
(
""
);
...
...
@@ -139,3 +146,41 @@ fn profile_block_import(c: &mut Criterion) {
},
);
}
struct
Setup
{
db
:
BenchDb
,
block
:
Block
,
}
impl
fmt
::
Debug
for
Setup
{
fn
fmt
(
&
self
,
f
:
&
mut
fmt
::
Formatter
<
'_
>
)
->
fmt
::
Result
{
write!
(
f
,
"Setup: {} tx/block"
,
self
.block.extrinsics
.len
())
}
}
fn
bench_wasm_size_import
(
c
:
&
mut
Criterion
)
{
sc_cli
::
init_logger
(
""
);
let
mut
setups
=
Vec
::
new
();
for
block_size
in
5
..
15
{
let
mut
db
=
BenchDb
::
new
(
block_size
*
50
);
let
block
=
db
.generate_block
(
block_size
*
50
);
setups
.push
(
Setup
{
db
,
block
});
}
c
.bench_function_over_inputs
(
"wasm_size_import"
,
move
|
bencher
,
setup
|
{
bencher
.iter_batched
(
||
{
setup
.db
.create_context
(
Profile
::
Wasm
)
},
|
mut
context
|
{
context
.import_block
(
setup
.block
.clone
());
},
criterion
::
BatchSize
::
PerIteration
,
);
},
setups
,
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment