File tree Expand file tree Collapse file tree 2 files changed +26
-24
lines changed Expand file tree Collapse file tree 2 files changed +26
-24
lines changed Original file line number Diff line number Diff line change 5
5
extends :
6
6
- prettier
7
7
parserOptions :
8
- ecmaVersion : 12
8
+ ecmaVersion : 13
9
9
ignorePatterns :
10
10
- " out/"
11
11
- " site/"
Original file line number Diff line number Diff line change @@ -232,32 +232,34 @@ function isPowerOfTwo(x) {
232
232
return x > 0 && ( ( x & ( x - 1 ) ) == 0 ) ;
233
233
}
234
234
235
- /** @constructor */
236
- globalThis . Benchmarker = function ( ) {
237
- const totals = { } ;
238
- const ids = [ ] ;
239
- const lastTime = 0 ;
240
- this . start = function ( id ) {
235
+ class Benchmarker {
236
+ totals = { } ;
237
+ ids = [ ] ;
238
+ lastTime = 0 ;
239
+
240
+ start ( id ) {
241
241
const now = Date . now ( ) ;
242
- if ( ids . length > 0 ) {
243
- totals [ ids [ ids . length - 1 ] ] += now - lastTime ;
242
+ if ( this . ids . length > 0 ) {
243
+ this . totals [ this . ids [ this . ids . length - 1 ] ] += now - this . lastTime ;
244
244
}
245
- lastTime = now ;
246
- ids . push ( id ) ;
247
- totals [ id ] ||= 0 ;
248
- } ;
249
- this . stop = function ( id ) {
245
+ this . lastTime = now ;
246
+ this . ids . push ( id ) ;
247
+ this . totals [ id ] ||= 0 ;
248
+ }
249
+
250
+ stop ( id ) {
250
251
const now = Date . now ( ) ;
251
- assert ( id === ids [ ids . length - 1 ] ) ;
252
- totals [ id ] += now - lastTime ;
253
- lastTime = now ;
254
- ids . pop ( ) ;
255
- } ;
256
- this . print = function ( text ) {
257
- const ids = Object . keys ( totals ) ;
252
+ assert ( id === this . ids [ this . ids . length - 1 ] ) ;
253
+ this . totals [ id ] += now - this . lastTime ;
254
+ this . lastTime = now ;
255
+ this . ids . pop ( ) ;
256
+ }
257
+
258
+ print ( text ) {
259
+ const ids = Object . keys ( this . totals ) ;
258
260
if ( ids . length > 0 ) {
259
- ids . sort ( ( a , b ) => totals [ b ] - totals [ a ] ) ;
260
- printErr ( text + ' times: \n' + ids . map ( ( id ) => id + ' : ' + totals [ id ] + ' ms' ) . join ( '\n' ) ) ;
261
+ ids . sort ( ( a , b ) => this . totals [ b ] - this . totals [ a ] ) ;
262
+ printErr ( text + ' times: \n' + ids . map ( ( id ) => id + ' : ' + this . totals [ id ] + ' ms' ) . join ( '\n' ) ) ;
261
263
}
262
- } ;
264
+ }
263
265
}
You can’t perform that action at this time.
0 commit comments