Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Duniter v2S
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
nodes
rust
Duniter v2S
Merge requests
!187
Distance pallet benchmark
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Distance pallet benchmark
bgallois/duniter-v2s:pallet-distance-benchmark
into
master
Overview
5
Commits
7
Pipelines
38
Changes
9
All threads resolved!
Hide all comments
Merged
Benjamin Gallois
requested to merge
bgallois/duniter-v2s:pallet-distance-benchmark
into
master
1 year ago
Overview
5
Commits
7
Pipelines
38
Changes
7
All threads resolved!
Hide all comments
Expand
0
0
Merge request reports
Compare
version 1
version 19
6cec1103
1 year ago
version 18
45b62973
1 year ago
version 17
45b62973
1 year ago
version 16
b2ab1db4
1 year ago
version 15
baef83b3
1 year ago
version 14
7c308146
1 year ago
version 13
f7221366
1 year ago
version 12
2578fad1
1 year ago
version 11
5ecf2fe7
1 year ago
version 10
859e8204
1 year ago
version 9
bbf95632
1 year ago
version 8
ca2de481
1 year ago
version 7
6c9538f0
1 year ago
version 6
eb80b819
1 year ago
version 5
c7ec9c4f
1 year ago
version 4
08fac5f8
1 year ago
version 3
1a5827be
1 year ago
version 2
c48cb991
1 year ago
version 1
7d3fae88
1 year ago
master (base)
and
version 6
latest version
41bdac4a
7 commits,
1 year ago
version 19
6cec1103
6 commits,
1 year ago
version 18
45b62973
7 commits,
1 year ago
version 17
45b62973
7 commits,
1 year ago
version 16
b2ab1db4
6 commits,
1 year ago
version 15
baef83b3
6 commits,
1 year ago
version 14
7c308146
5 commits,
1 year ago
version 13
f7221366
5 commits,
1 year ago
version 12
2578fad1
5 commits,
1 year ago
version 11
5ecf2fe7
4 commits,
1 year ago
version 10
859e8204
4 commits,
1 year ago
version 9
bbf95632
4 commits,
1 year ago
version 8
ca2de481
4 commits,
1 year ago
version 7
6c9538f0
3 commits,
1 year ago
version 6
eb80b819
2 commits,
1 year ago
version 5
c7ec9c4f
2 commits,
1 year ago
version 4
08fac5f8
2 commits,
1 year ago
version 3
1a5827be
2 commits,
1 year ago
version 2
c48cb991
2 commits,
1 year ago
version 1
7d3fae88
1 commit,
1 year ago
Show latest version
7 files
+
120
−
7
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
7
Search (e.g. *.vue) (Ctrl+P)
pallets/distance/src/benchmarking.rs
0 → 100644
+
83
−
0
Options
// Copyright 2021-2023 Axiom-Team
//
// This file is part of Duniter-v2S.
//
// Duniter-v2S is free software: you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation, version 3 of the License.
//
// Duniter-v2S is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with Duniter-v2S. If not, see <https://www.gnu.org/licenses/>.
#![cfg(feature
=
"runtime-benchmarks"
)]
use
super
::
*
;
use
frame_benchmarking
::{
benchmarks
,
vec
};
use
frame_support
::
traits
::{
Currency
,
OnFinalize
};
use
frame_system
::
RawOrigin
;
use
pallet_balances
::
Pallet
as
Balances
;
use
sp_runtime
::
traits
::{
Bounded
,
One
};
use
sp_runtime
::
Perbill
;
use
crate
::
Pallet
;
fn
populate_pool
<
T
:
Config
>
(
i
:
u32
)
->
Result
<
(),
&
'static
str
>
{
EvaluationPool0
::
<
T
>
::
mutate
(|
current_pool
|
->
Result
<
(),
&
'static
str
>
{
for
j
in
0
..
i
{
current_pool
.evaluations
.try_push
((
j
.into
(),
median
::
MedianAcc
::
new
()))
.map_err
(|
_
|
Error
::
<
T
>
::
QueueFull
)
?
;
}
Ok
(())
})
}
benchmarks!
{
where_clause
{
where
T
:
pallet_balances
::
Config
,
T
::
Balance
:
From
<
u64
>
,
T
::
BlockNumber
:
From
<
u32
>
,
}
request_distance_evaluation
{
let
idty
=
T
::
IdtyIndex
::
one
();
let
caller
:
T
::
AccountId
=
pallet_identity
::
Identities
::
<
T
>
::
get
(
idty
)
.unwrap
()
.owner_key
;
let
caller_origin
:
<
T
as
frame_system
::
Config
>
::
RuntimeOrigin
=
RawOrigin
::
Signed
(
caller
.clone
())
.into
();
let
_
=
<
Balances
<
T
>
as
Currency
<
_
>>
::
make_free_balance_be
(
&
caller
,
T
::
Balance
::
max_value
());
}:
_
<
T
::
RuntimeOrigin
>
(
caller_origin
.clone
())
verify
{
assert!
(
IdentityDistanceStatus
::
<
T
>
::
get
(
&
idty
)
==
Some
((
caller
,
DistanceStatus
::
Pending
)),
"Request not added"
);
}
update_evaluation
{
let
idty
=
T
::
IdtyIndex
::
one
();
let
caller
:
T
::
AccountId
=
pallet_identity
::
Identities
::
<
T
>
::
get
(
idty
)
.unwrap
()
.owner_key
;
let
caller_origin
:
<
T
as
frame_system
::
Config
>
::
RuntimeOrigin
=
RawOrigin
::
Signed
(
caller
.clone
())
.into
();
let
i
in
1
..
MAX_EVALUATIONS_PER_SESSION
=>
populate_pool
::
<
T
>
(
i
)
?
;
}:
_
<
T
::
RuntimeOrigin
>
(
RawOrigin
::
None
.into
(),
ComputationResult
{
distances
:
vec!
[
Perbill
::
one
();
i
as
usize
]})
force_update_evaluation
{
let
idty
=
T
::
IdtyIndex
::
one
();
let
caller
:
T
::
AccountId
=
pallet_identity
::
Identities
::
<
T
>
::
get
(
idty
)
.unwrap
()
.owner_key
;
let
caller_origin
:
<
T
as
frame_system
::
Config
>
::
RuntimeOrigin
=
RawOrigin
::
Signed
(
caller
.clone
())
.into
();
let
i
in
1
..
MAX_EVALUATIONS_PER_SESSION
=>
populate_pool
::
<
T
>
(
i
)
?
;
}:
_
<
T
::
RuntimeOrigin
>
(
RawOrigin
::
Root
.into
(),
caller
,
ComputationResult
{
distances
:
vec!
[
Perbill
::
one
();
i
as
usize
]})
force_set_distance_status
{
let
idty
=
T
::
IdtyIndex
::
one
();
let
caller
:
T
::
AccountId
=
pallet_identity
::
Identities
::
<
T
>
::
get
(
idty
)
.unwrap
()
.owner_key
;
let
status
=
Some
((
caller
.clone
(),
DistanceStatus
::
Valid
));
}:
_
<
T
::
RuntimeOrigin
>
(
RawOrigin
::
Root
.into
(),
idty
,
status
)
verify
{
assert!
(
IdentityDistanceStatus
::
<
T
>
::
get
(
&
idty
)
==
Some
((
caller
,
DistanceStatus
::
Valid
)),
"Status not set"
);
}
on_finalize
{
DidUpdate
::
<
T
>
::
set
(
true
);
}:
{
Pallet
::
<
T
>
::
on_finalize
(
Default
::
default
());
}
verify
{
assert!
(
!
DidUpdate
::
<
T
>
::
get
());
}
}
Loading