File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -305,21 +305,34 @@ Date.prototype.formatDate = function (input,time) {
305305
306306function run ( ) {
307307 var date = new Date ( "1/1/2007 1:11:11" ) ;
308+ var resultHash = 0x1a2b3c4d ;
308309
309310 for ( i = 0 ; i < 500 ; ++ i ) {
310311 var shortFormat = date . formatDate ( "Y-m-d" ) ;
311312 var longFormat = date . formatDate ( "l, F d, Y g:i:s A" ) ;
312313 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 ;
313317 }
314318
315319 // FIXME: Find a way to validate this test.
316320 // https://bugs.webkit.org/show_bug.cgi?id=114849
321+ return resultHash ;
317322}
318323
319324
320325class Benchmark {
326+ EXPECTED_RESULT_HASH = 439041101 ;
327+
321328 runIteration ( ) {
329+ this . resultHash = 0x1a2b3c4d ;
322330 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 } ` )
324337 }
325338}
Original file line number Diff line number Diff line change @@ -410,21 +410,34 @@ Date.patterns = {
410410
411411function run ( ) {
412412 var date = new Date ( "1/1/2007 1:11:11" ) ;
413+ var resultHash = 0x1a2b3c4d ;
413414
414415 for ( i = 0 ; i < 4000 ; ++ i ) {
415416 var shortFormat = date . dateFormat ( "Y-m-d" ) ;
416417 var longFormat = date . dateFormat ( "l, F d, Y g:i:s A" ) ;
417418 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 ;
418422 }
419423
420424 // FIXME: Find a way to validate this test.
421425 // https://bugs.webkit.org/show_bug.cgi?id=114849
426+ return resultHash ;
422427}
423428
424429
425430class Benchmark {
431+ EXPECTED_RESULT_HASH = 439041101 ;
432+
426433 runIteration ( ) {
434+ this . resultHash = 0x1a2b3c4d ;
427435 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 } ` )
429442 }
430443}
You can’t perform that action at this time.
0 commit comments