Skip to content

Fix benchmarking rangeEx #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions JavaScript/5-range.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
'use strict';

const benchmark = require('./2-benchmark.js');
const common = require('metarhia-common');
const os = require('os');

const rangePush = (min, max) => {
const arr = [];
Expand All @@ -24,14 +26,14 @@ const rangeEx = range => {
const toType = typeof to;
if (toType === 'undefined') {
to = range[2];
return api.common.range(from, to);
return common.range(from, to);
} else if (toType !== 'number') {
let count = to[0];
if (count < 0) {
const cpus = api.os.cpus().length;
const cpus = os.cpus().length;
count = cpus + count;
}
return api.common.range(from, from + count - 1);
return common.range(from, from + count - 1);
}
};

Expand All @@ -43,6 +45,6 @@ benchmark.do(1000000, [
rangeNew(1, 1000);
},
function testRangeEx() {
rangeNew(1, 1000);
rangeEx([1, [1000]]);
},
]);