File tree 2 files changed +14
-5
lines changed
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change 1
1
'use strict' ;
2
2
3
- export default async function exec ( benchmark , mode ) {
3
+ export default async function exec ( benchmark , mode , time ) {
4
4
let SVM ;
5
5
if ( mode === 'asm' ) {
6
6
SVM = await import ( '../asm' ) ;
@@ -10,8 +10,8 @@ export default async function exec(benchmark, mode) {
10
10
throw new Error ( 'Invalid mode' ) ;
11
11
}
12
12
13
- const count = benchmark ( SVM ) ;
14
- console . log ( `${ mode } : ${ count } iterations.` ) ;
13
+ const count = benchmark ( SVM , time ) ;
14
+ console . log ( `${ mode } : ${ count } iterations in ${ time } seconds .` ) ;
15
15
16
16
return count ;
17
17
}
Original file line number Diff line number Diff line change @@ -7,11 +7,14 @@ export default class Benchmarks extends Component {
7
7
this . state = { } ;
8
8
}
9
9
async onRun ( ) {
10
- const asmTime = await runBenchmark ( this . props . benchmark , 'asm' ) ;
10
+ const asmTime = await runBenchmark ( this . props . benchmark , 'asm' , 5 ) ;
11
11
this . setState ( {
12
12
asmTime
13
13
} ) ;
14
- const wasmTime = await runBenchmark ( this . props . benchmark , 'wasm' ) ;
14
+
15
+ await wait ( ) ;
16
+
17
+ const wasmTime = await runBenchmark ( this . props . benchmark , 'wasm' , 5 ) ;
15
18
this . setState ( {
16
19
wasmTime
17
20
} ) ;
@@ -27,3 +30,9 @@ export default class Benchmarks extends Component {
27
30
)
28
31
}
29
32
}
33
+
34
+ function wait ( ) {
35
+ return new Promise ( resolve => {
36
+ setTimeout ( resolve , 0 ) ;
37
+ } ) ;
38
+ }
You can’t perform that action at this time.
0 commit comments