simulate range of python

JavaScript performance comparison

Test case created by kerryChen95

Preparation code

<script src=""></script>
function arrayApplyAndMap (start, end, step) {
  if (arguments.length <= 1) {
    end = start || 0;
    start = 0;
  step = step || 1;
  return Array.apply(null, new Array( Math.max(Math.ceil( (end - start) / step ), 0) )).map(function (val, i) { return i * step + start; });

var underscore1_4_4 = _.range;

var longLengthSmallStep = [1, 10000, 1];
var longLengthLargeStep = [1, 10000, 1000];
var shortLength = [1, 5];

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
array apply and map
arrayApplyAndMap.apply(null, longLengthSmallStep);
arrayApplyAndMap.apply(null, longLengthLargeStep);
arrayApplyAndMap.apply(null, shortLength);
underscore1_4_4.apply(null, longLengthSmallStep);
underscore1_4_4.apply(null, longLengthLargeStep);
underscore1_4_4.apply(null, shortLength);

Compare results of other browsers


You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:


Comment form temporarily disabled.

Add a comment