File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,34 @@ global.benchmarkRunner = function(name, body) {
9
9
console . log ( "done " + ( endTime - startTime ) + " ms" ) ;
10
10
}
11
11
12
+ class JSBenchmark {
13
+ constructor ( title ) { this . title = title }
14
+ testSuite ( name , body ) {
15
+ benchmarkRunner ( `${ this . title } /${ name } ` , ( iteration ) => {
16
+ for ( let idx = 0 ; idx < iteration ; idx ++ ) {
17
+ body ( )
18
+ }
19
+ } )
20
+ }
21
+ }
22
+
23
+ const serialization = new JSBenchmark ( "Serialization" )
24
+ serialization . testSuite ( "Write JavaScript number directly" , ( ) => {
25
+ const jsNumber = 42
26
+ const object = global
27
+ for ( let idx = 0 ; idx < 100 ; idx ++ ) {
28
+ object [ "numberValue" + idx ] = jsNumber
29
+ }
30
+ } )
31
+
32
+ serialization . testSuite ( "Write JavaScript string directly" , ( ) => {
33
+ const jsString = "Hello, world"
34
+ const object = global
35
+ for ( let idx = 0 ; idx < 100 ; idx ++ ) {
36
+ object [ "stringValue" + idx ] = jsString
37
+ }
38
+ } )
39
+
12
40
startWasiTask ( "./dist/BenchmarkTests.wasm" ) . catch ( err => {
13
41
console . log ( err )
14
42
} ) ;
You can’t perform that action at this time.
0 commit comments