Skip to content
This repository was archived by the owner on Nov 8, 2021. It is now read-only.

Commit

Permalink
Refactor the benchmarks slightly
Browse files Browse the repository at this point in the history
  • Loading branch information
koute committed Jul 18, 2018
1 parent 4e0a2f7 commit 3926e80
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions benchmarks/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ impl Bencher {
}
}

fn main() {
fn run_benchmarks< F: FnOnce( &mut Bencher ) >( callback: F ) {
if !*IS_NODEJS {
let body = document().query_selector( "body" ).unwrap().unwrap();
let start = document().create_element( "button" ).unwrap();
Expand All @@ -122,9 +122,7 @@ fn main() {
}

let mut bencher = Bencher::new();
bencher.add( "call-into-js", || js!( @(no_return) ) );
bencher.add( "call-into-js-returning-undefined", || js!() );
bencher.add( "call-into-js-with-string", || js!( @(no_return) var test = @{"Hello world!"}; ) );
callback( &mut bencher );

if !*IS_NODEJS {
let body = document().query_selector( "body" ).unwrap().unwrap();
Expand All @@ -135,3 +133,11 @@ fn main() {
bencher.run();
}
}

fn main() {
run_benchmarks( |bencher| {
bencher.add( "call-into-js", || js!( @(no_return) ) );
bencher.add( "call-into-js-returning-undefined", || js!() );
bencher.add( "call-into-js-with-string", || js!( @(no_return) var test = @{"Hello world!"}; ) );
});
}

0 comments on commit 3926e80

Please sign in to comment.