File tree 2 files changed +28
-2
lines changed
2 files changed +28
-2
lines changed Original file line number Diff line number Diff line change @@ -305,21 +305,34 @@ Date.prototype.formatDate = function (input,time) {
305
305
306
306
function run ( ) {
307
307
var date = new Date ( "1/1/2007 1:11:11" ) ;
308
+ var resultHash = 0x1a2b3c4d ;
308
309
309
310
for ( i = 0 ; i < 500 ; ++ i ) {
310
311
var shortFormat = date . formatDate ( "Y-m-d" ) ;
311
312
var longFormat = date . formatDate ( "l, F d, Y g:i:s A" ) ;
312
313
date . setTime ( date . getTime ( ) + 84266956 ) ;
314
+ // Assuming only ascii output.
315
+ resultHash ^= shortFormat . charCodeAt ( 6 ) | shortFormat . charCodeAt ( 8 ) << 8 ;
316
+ resultHash ^= longFormat . charCodeAt ( 10 ) << 16 | longFormat . charCodeAt ( 11 ) << 24 ;
313
317
}
314
318
315
319
// FIXME: Find a way to validate this test.
316
320
// https://bugs.webkit.org/show_bug.cgi?id=114849
321
+ return resultHash ;
317
322
}
318
323
319
324
320
325
class Benchmark {
326
+ EXPECTED_RESULT_HASH = 439041101 ;
327
+
321
328
runIteration ( ) {
329
+ this . resultHash = 0x1a2b3c4d ;
322
330
for ( let i = 0 ; i < 8 ; ++ i )
323
- run ( ) ;
331
+ this . resultHash ^= run ( ) ;
332
+ }
333
+
334
+ validate ( ) {
335
+ if ( this . resultHash != this . EXPECTED_RESULT_HASH )
336
+ throw new Error ( `Got unexpected result hash ${ this . resultHash } instead of ${ this . EXPECTED_RESULT_HASH } ` )
324
337
}
325
338
}
Original file line number Diff line number Diff line change @@ -410,21 +410,34 @@ Date.patterns = {
410
410
411
411
function run ( ) {
412
412
var date = new Date ( "1/1/2007 1:11:11" ) ;
413
+ var resultHash = 0x1a2b3c4d ;
413
414
414
415
for ( i = 0 ; i < 4000 ; ++ i ) {
415
416
var shortFormat = date . dateFormat ( "Y-m-d" ) ;
416
417
var longFormat = date . dateFormat ( "l, F d, Y g:i:s A" ) ;
417
418
date . setTime ( date . getTime ( ) + 84266956 ) ;
419
+ // Assuming only ascii output.
420
+ resultHash ^= shortFormat . charCodeAt ( 6 ) | shortFormat . charCodeAt ( 8 ) << 8 ;
421
+ resultHash ^= longFormat . charCodeAt ( 10 ) << 16 | longFormat . charCodeAt ( 11 ) << 24 ;
418
422
}
419
423
420
424
// FIXME: Find a way to validate this test.
421
425
// https://bugs.webkit.org/show_bug.cgi?id=114849
426
+ return resultHash ;
422
427
}
423
428
424
429
425
430
class Benchmark {
431
+ EXPECTED_RESULT_HASH = 439041101 ;
432
+
426
433
runIteration ( ) {
434
+ this . resultHash = 0x1a2b3c4d ;
427
435
for ( let i = 0 ; i < 8 ; ++ i )
428
- run ( ) ;
436
+ this . resultHash ^= run ( ) ;
437
+ }
438
+
439
+ validate ( ) {
440
+ if ( this . resultHash != this . EXPECTED_RESULT_HASH )
441
+ throw new Error ( `Got unexpected result hash ${ this . resultHash } instead of ${ this . EXPECTED_RESULT_HASH } ` )
429
442
}
430
443
}
You can’t perform that action at this time.
0 commit comments