Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
PLNK - a simple Rust benchmark framework
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container 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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
STEVAN Antoine
PLNK - a simple Rust benchmark framework
Commits
6768cb5b
Verified
Commit
6768cb5b
authored
1 month ago
by
STEVAN Antoine
Browse files
Options
Downloads
Patches
Plain Diff
pass progress bar to benchmarking closure
parent
1ff7b083
Branches
main
No related tags found
No related merge requests found
Pipeline
#9238
passed
1 month ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/arithmetic.rs
+1
-1
1 addition, 1 deletion
examples/arithmetic.rs
src/lib.rs
+6
-3
6 additions, 3 deletions
src/lib.rs
with
7 additions
and
4 deletions
examples/arithmetic.rs
+
1
−
1
View file @
6768cb5b
...
...
@@ -38,7 +38,7 @@ fn arithmetic(b: &plnk::Bencher) {
fn
random
(
b
:
&
plnk
::
Bencher
)
{
b
.bench
(
plnk
::
label!
{
operation
:
"sampling"
},
plnk
::
closure!
{
plnk
::
timeit
(||
rand
::
thread_rng
()
.gen
::
<
u128
>
())},
plnk
::
closure!
{
plnk
::
timeit
(||
rand
::
thread_rng
()
.gen
::
<
u128
>
())
},
);
}
...
...
This diff is collapsed.
Click to expand it.
src/lib.rs
+
6
−
3
View file @
6768cb5b
...
...
@@ -9,7 +9,7 @@ use std::{
use
indicatif
::{
MultiProgress
,
ProgressBar
,
ProgressStyle
};
pub
type
FnTimed
<
T
>
=
Box
<
dyn
Fn
()
->
TimeWithValue
<
T
>>
;
pub
type
FnTimed
<
T
>
=
Box
<
dyn
Fn
(
ProgressBar
)
->
TimeWithValue
<
T
>>
;
pub
struct
LabeledFnTimed
<
T
>
{
pub
label
:
String
,
...
...
@@ -147,7 +147,7 @@ impl Bencher {
let
mut
times
=
vec!
[];
for
_
in
0
..
self
.nb_measurements
{
let
TimeWithValue
{
t
,
v
}
=
func
();
let
TimeWithValue
{
t
,
v
}
=
func
(
pb
.clone
()
);
res
=
Some
(
v
);
times
.push
(
t
.as_nanos
());
...
...
@@ -190,8 +190,11 @@ impl Bencher {
#[macro_export]
macro_rules!
closure
{
(
$pb:ident
,
$
(
$body:stmt
);
*
$
(;)
?
)
=>
{
Box
::
new
(
move
|
$pb
:
indicatif
::
ProgressBar
|
{
$
(
$body
)
*
})
as
plnk
::
FnTimed
<
_
>
};
(
$
(
$body:stmt
);
*
$
(;)
?
)
=>
{
Box
::
new
(
move
||
{
$
(
$body
)
*
})
as
plnk
::
FnTimed
<
_
>
Box
::
new
(
move
|
_
|
{
$
(
$body
)
*
})
as
plnk
::
FnTimed
<
_
>
};
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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