Skip to content

Commit e1ef8d7

Browse files
committed
hash date formatting result
1 parent 901c95b commit e1ef8d7

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

SunSpider/date-format-tofte.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,21 +291,26 @@ Date.prototype.formatDate = function (input,time) {
291291

292292
function run() {
293293
var date = new Date("1/1/2007 1:11:11");
294+
var resultHash = 0x1a2b3c4d;
294295

295296
for (i = 0; i < 500; ++i) {
296297
var shortFormat = date.formatDate("Y-m-d");
297298
var longFormat = date.formatDate("l, F d, Y g:i:s A");
298299
date.setTime(date.getTime() + 84266956);
300+
resultHash ^= shortFormat.charCodeAt(6) | shortFormat.charCodeAt(8) << 8;
301+
resultHash ^= longFormat.charCodeAt(10) << 16 | longFormat.charCodeAt(11) << 24;
299302
}
300303

301304
// FIXME: Find a way to validate this test.
302305
// https://bugs.webkit.org/show_bug.cgi?id=114849
306+
return resultHash;
303307
}
304308

305309

306310
class Benchmark {
307311
runIteration() {
312+
this.resultHash = 0x1a2b3c4d;
308313
for (let i = 0; i < 8; ++i)
309-
run();
314+
this.resultHash ^= run();
310315
}
311316
}

SunSpider/date-format-xparb.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,21 +410,26 @@ Date.patterns = {
410410

411411
function 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+
resultHash ^= shortFormat.charCodeAt(6) | shortFormat.charCodeAt(8) << 8;
420+
resultHash ^= longFormat.charCodeAt(10) << 16 | longFormat.charCodeAt(11) << 24;
418421
}
419422

420423
// FIXME: Find a way to validate this test.
421424
// https://bugs.webkit.org/show_bug.cgi?id=114849
425+
return resultHash;
422426
}
423427

424428

425429
class Benchmark {
426430
runIteration() {
431+
this.resultHash = 0x1a2b3c4d;
427432
for (let i = 0; i < 8; ++i)
428-
run();
433+
this.resultHash ^= run();
429434
}
430435
}

0 commit comments

Comments
 (0)