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
a44527b2
Commit
a44527b2
authored
3 years ago
by
thiolliere
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix benchmark writer (#9626)
* fix benchmark writer * update doc to show the more general implementation
parent
10268c5b
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
substrate/utils/frame/benchmarking-cli/src/writer.rs
+4
-19
4 additions, 19 deletions
substrate/utils/frame/benchmarking-cli/src/writer.rs
with
4 additions
and
19 deletions
substrate/utils/frame/benchmarking-cli/src/writer.rs
+
4
−
19
View file @
a44527b2
...
...
@@ -107,7 +107,7 @@ fn io_error(s: &str) -> std::io::Error {
}
// This function takes a list of `BenchmarkBatch` and organizes them by pallet into a `HashMap`.
// So this: `[(p1, b1), (p1, b2), (p
1
, b
3
), (p
2
, b
1
), (p2, b2)]`
// So this: `[(p1, b1), (p1, b2), (p
2
, b
1
), (p
1
, b
3
), (p2, b2)]`
// Becomes:
//
// ```
...
...
@@ -124,11 +124,9 @@ fn map_results(
return
Err
(
io_error
(
"empty batches"
))
}
let
mut
all_benchmarks
=
HashMap
::
new
();
let
mut
pallet_benchmarks
=
Vec
::
new
();
let
mut
all_benchmarks
=
HashMap
::
<
_
,
Vec
<
BenchmarkData
>>
::
new
();
let
mut
batches_iter
=
batches
.iter
()
.peekable
();
while
let
Some
(
batch
)
=
batches_iter
.next
()
{
for
batch
in
batches
{
// Skip if there are no results
if
batch
.time_results
.is_empty
()
{
continue
...
...
@@ -137,21 +135,8 @@ fn map_results(
let
pallet_string
=
String
::
from_utf8
(
batch
.pallet
.clone
())
.unwrap
();
let
instance_string
=
String
::
from_utf8
(
batch
.instance
.clone
())
.unwrap
();
let
benchmark_data
=
get_benchmark_data
(
batch
,
storage_info
,
analysis_choice
);
let
pallet_benchmarks
=
all_benchmarks
.entry
((
pallet_string
,
instance_string
))
.or_default
();
pallet_benchmarks
.push
(
benchmark_data
);
// Check if this is the end of the iterator
if
let
Some
(
next
)
=
batches_iter
.peek
()
{
// Next pallet is different than current pallet, save and create new data.
let
next_pallet
=
String
::
from_utf8
(
next
.pallet
.clone
())
.unwrap
();
let
next_instance
=
String
::
from_utf8
(
next
.instance
.clone
())
.unwrap
();
if
next_pallet
!=
pallet_string
||
next_instance
!=
instance_string
{
all_benchmarks
.insert
((
pallet_string
,
instance_string
),
pallet_benchmarks
.clone
());
pallet_benchmarks
=
Vec
::
new
();
}
}
else
{
// This is the end of the iterator, so push the final data.
all_benchmarks
.insert
((
pallet_string
,
instance_string
),
pallet_benchmarks
.clone
());
}
}
Ok
(
all_benchmarks
)
}
...
...
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