File tree 1 file changed +43
-0
lines changed
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ 'use strict' ;
2
+
3
+ const common = require ( '../common.js' ) ;
4
+ const assert = require ( 'assert' ) ;
5
+
6
+ const bench = common . createBenchmark ( main , {
7
+ n : [ 25 , 2e5 ] ,
8
+ type : [ 'string' , 'object' , 'number' ] ,
9
+ method : [ 'strictEqual' , 'notStrictEqual' ] ,
10
+ } ) ;
11
+
12
+ function main ( { type, n, method } ) {
13
+ const fn = assert [ method ] ;
14
+ let actual , expected ;
15
+ switch ( type ) {
16
+ case 'string' :
17
+ actual = expected = 'Hello World' ;
18
+ if ( method === 'notStrictEqual' ) {
19
+ expected += 'bar' ;
20
+ }
21
+ break ;
22
+ case 'object' :
23
+ actual = expected = { a : 'Hello' , b : 'World' } ;
24
+ if ( method === 'notStrictEqual' ) {
25
+ expected = { a : 'Hello' , b : 'World' } ;
26
+ }
27
+ break ;
28
+ case 'number' :
29
+ actual = expected = 1e9 ;
30
+ if ( method === 'notStrictEqual' ) {
31
+ expected += 1 ;
32
+ }
33
+ break ;
34
+ default :
35
+ throw new Error ( 'Unexpected type' ) ;
36
+ }
37
+
38
+ bench . start ( ) ;
39
+ for ( let i = 0 ; i < n ; ++ i ) {
40
+ fn ( actual , expected ) ;
41
+ }
42
+ bench . end ( n ) ;
43
+ }
You can’t perform that action at this time.
0 commit comments