repositories
/
benchmarks-js.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'master' into combined-prs-branch
[benchmarks-js.git]
/
max.mjs
diff --git
a/max.mjs
b/max.mjs
index 778c0efb7ad87d27c8031275ed572cde2e8d2cdc..12b458c66f30f53438339c7f8034a491685a93f0 100644
(file)
--- a/
max.mjs
+++ b/
max.mjs
@@
-1,4
+1,4
@@
-import { bench, group, run } from '
mitata
'
+import { bench, group, run } from '
tatami-ng
'
import { generateRandomNumberArray } from './benchmark-utils.mjs'
import { generateRandomNumberArray } from './benchmark-utils.mjs'
@@
-11,7
+11,7
@@
const testArray = generateRandomNumberArray(size)
* @returns
*/
function loopMax (values) {
* @returns
*/
function loopMax (values) {
- let maximum =
-Infinity
+ let maximum =
Number.NEGATIVE_INFINITY
for (const value of values) {
if (value > maximum) maximum = value
}
for (const value of values) {
if (value > maximum) maximum = value
}
@@
-26,7
+26,7
@@
function loopMax (values) {
function reduceTernaryMax (values) {
return values.reduce(
(maximum, num) => (maximum > num ? maximum : num),
function reduceTernaryMax (values) {
return values.reduce(
(maximum, num) => (maximum > num ? maximum : num),
- -Infinity
+ Number.NEGATIVE_INFINITY
)
}
)
}
@@
-36,7
+36,10
@@
function reduceTernaryMax (values) {
* @returns
*/
function reduceMathMax (values) {
* @returns
*/
function reduceMathMax (values) {
- return values.reduce((maximum, num) => Math.max(maximum, num), -Infinity)
+ return values.reduce(
+ (maximum, num) => Math.max(maximum, num),
+ Number.NEGATIVE_INFINITY
+ )
}
/**
}
/**
@@
-67,5
+70,5
@@
group(`Max from ${size} numbers`, () => {
})
await run({
})
await run({
- units: true
+ units: true
,
})
})