This repository has been archived by the owner on Oct 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 340
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
meta: merge node/master into node-chakracore/master
Merge 120ea9b as of 2017-12-28 This commit was automatically generated. For any problems, please contact jackhorton Reviewed-By: Taylor Woll <tawoll@ntdev.microsoft.com>
- Loading branch information
Showing
53 changed files
with
1,027 additions
and
587 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
'use strict'; | ||
const common = require('../common.js'); | ||
|
||
const bench = common.createBenchmark(main, { | ||
noAssert: ['false', 'true'], | ||
type: ['Double', 'Float'], | ||
endian: ['BE', 'LE'], | ||
value: ['zero', 'big', 'small', 'inf', 'nan'], | ||
millions: [1] | ||
}); | ||
|
||
function main(conf) { | ||
const noAssert = conf.noAssert === 'true'; | ||
const len = +conf.millions * 1e6; | ||
const buff = Buffer.alloc(8); | ||
const type = conf.type || 'Double'; | ||
const endian = conf.endian; | ||
const fn = `read${type}${endian}`; | ||
const values = { | ||
Double: { | ||
zero: 0, | ||
big: 2 ** 1023, | ||
small: 2 ** -1074, | ||
inf: Infinity, | ||
nan: NaN, | ||
}, | ||
Float: { | ||
zero: 0, | ||
big: 2 ** 127, | ||
small: 2 ** -149, | ||
inf: Infinity, | ||
nan: NaN, | ||
}, | ||
}; | ||
const value = values[type][conf.value]; | ||
|
||
buff[`write${type}${endian}`](value, 0, noAssert); | ||
const testFunction = new Function('buff', ` | ||
for (var i = 0; i !== ${len}; i++) { | ||
buff.${fn}(0, ${JSON.stringify(noAssert)}); | ||
} | ||
`); | ||
bench.start(); | ||
testFunction(buff); | ||
bench.end(len / 1e6); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.