build(deps-dev): apply updates
[benchmarks-js.git] / max.js
diff --git a/max.js b/max.js
index bfa521cce36722fc35f72dc991d48fd9413b2e4a..5a486473e9d6fa3afa4aa7da9347ce6384a28e49 100644 (file)
--- a/max.js
+++ b/max.js
@@ -1,11 +1,13 @@
 const Benchmark = require('benny')
 const { generateRandomNumberArray } = require('./benchmark-utils')
 
-const testArray = generateRandomNumberArray(10000)
+const size = 10000
+const testArray = generateRandomNumberArray(size)
 
 /**
  *
  * @param values
+ * @returns
  */
 function loopMax (values) {
   let max = -Infinity
@@ -18,6 +20,7 @@ function loopMax (values) {
 /**
  *
  * @param values
+ * @returns
  */
 function reduceTernaryMax (values) {
   return values.reduce((a, b) => (a > b ? a : b), -Infinity)
@@ -26,6 +29,7 @@ function reduceTernaryMax (values) {
 /**
  *
  * @param values
+ * @returns
  */
 function reduceMathMax (values) {
   return values.reduce((a, b) => Math.max(a, b), -Infinity)
@@ -34,13 +38,14 @@ function reduceMathMax (values) {
 /**
  *
  * @param values
+ * @returns
  */
 function sortMax (values) {
   return values.sort((a, b) => b - a)[0]
 }
 
 Benchmark.suite(
-  'max',
+  `Max from ${size} numbers`,
   Benchmark.add('Math.max', () => {
     Math.max(...testArray)
   }),
@@ -61,4 +66,6 @@ Benchmark.suite(
   Benchmark.save({ file: 'max', format: 'json', details: true }),
   Benchmark.save({ file: 'max', format: 'chart.html', details: true }),
   Benchmark.save({ file: 'max', format: 'table.html', details: true })
-)
+).catch(err => {
+  console.error(err)
+})