String split

JavaScript performance comparison

Test case created by Alex

Preparation code

 
<script>
Benchmark.prototype.setup = function() {
    var string = "10,36,39,40,52,61,66,76,90,97,114,134,148,156,165,170,172,183,190,194,211,248,266,269,270,295,297,302,345,353,354,358,364,397,402,418,420,466,479,480,489,496,513,516,534,555,558,559,565,575,579,581,584,585,615,632,637,639,642,643,644,655,659,664,665,670,692,732,734,740,754,762,766,772,786,793,794,806,812,817,825,840,849,878,888,898,911,915,917,918,929,930,936,947,957,958,963,973,977,979,982,994,996,1008,1010,1023,1038,1039,1043,1051,1060,1081,1095,1096,1108,1110,1144,1156,1165,1166,1170,1184,1194,1206,1212,1221,1222,1227,1236,1244,1256,1260,1271,1284,1289,1290,1314,1322,1327,1358,1369,1403,1406,1413,1422,1425,1427,1438,1439,1440,1444,1446,1457,1460,1467,1468,1470,1482,1486,1488,1496,1499,1501,1507,1517,1523,1533,1551,1563,1566,1576,1599,1616,1628,1692,1700,1707,1721,1724,1737,1756,1758,1773,1783,1784,1787,1800,1804,1822,1826,1836,1845,1872,1922,1927,1953,1955,1975,1977,1984,2014,2018,2025,2030,2034,2036,2044,2048,2058,2070,2092,2093,2109,2118,2132,2133,2149,2165,2170,2196,2212,2215,2217,2230,2272,2287,2290,2299,2304,2308,2311,2318,2322,2333,2335,2341,2352,2356,2365,2372,2375,2400,2409,2453,2454,2461,2464,2479,2480,2487,2493,2508,2509,2533,2541,2560,2566,2570,2573,2577,2600,2601,2611,2617,2618,2627,2637,2643,2655,2670,2687,2692,2697,2698,2701,2720,2727,2744,2754,2778,2786,2793,2798,2800,2806,2813,2820,2824,2841,2842,2846,2864,2866,2870,2872,2875,2914,2936,2943,2962,2971,3006,3036,3042,3051,3055,3057,3064,3072,3083,3089,3096,3099,3115,3120,3141,3169,3183,3187,3200,3215,3216,3236,3239,3241,3268,3271,3277,3280,3281,3304,3323,3356,3368,3370,3372,3373,3388,3402,3407,3431,3441,3446,3483,3488,3489,3493,3494,3503,3506,3520,3523,3525,3529,3538,3540,3543,3551,3560,3570,3574,3590,3608,3610,3614,3627,3636,3655,3658,3665,3683,3689,3708,3719,3733,3737,3743,3745,3747,3754,3757,3762,3768,3774,3789,3791,3799,3801,3803,3815,3826,3832,3845,3861,3875,3894,3896,3909,3912,3947,3948,3954,3970,3977,3979,3980,4002,4004,4009,4019,4022,4035,4047,4049,4060,4065,4075,4085,4094,4103,4104,4113,4119,4124,4168,4180,4184,4189,4198,4200,4205,4211,4220,4229,4261,4262,4275,4287,4296,4317,4320,4330,4338,4343,4350,4353,4358,4379,4391,4397,4398,4399,4428,4433,4436,4441,4453,4455,4468,4474,4476,4499,4570,4581,4609,4612,4619,4620,4628,4645,4649,4664,4674,4677,4697,4698,4703,4723,4727,4735,4739,4740,4741,4742,4776,4782,4804,4813,4821,4823,4839,4846,4849,4856,4887,4894,4901,4903,4904,4925,4929,4952,4964,4965,4969,4985,5000,5010,5011,5013,5016,5045,5054,5073,5089,5094,5097,5100,5102,5110,5138,5139,5145,5158,5159,5160,5178,5183,5193,5197,5215,5217,5218,5250,5252,5289,5297,5309,5326,5328,5335,5343,5356,5366,5367,5373,5375,5376,5413,5421,5426,5428,5446,5450,5452,5467,5471,5478,5479,5494,5505,5507,5518,5524,5531,5532,5538,5550,5560,5590,5594,5599,5606,5608,5633,5636,5638,5647,5650,5651,5662,5677,5683,5700,5706,5707,5722,5725,5742,5743,5754,5755,5760,5780,5795,5820,5828,5830,5879,5891,5893,5894,5900,5921,5943,5960,5974,5982,5993,5998,6004,6028,6041,6044,6054,6068,6073,6092,6097,6106,6113,6116,6120,6121,6134,6142,6143,6155,6171,6175,6186,6204,6208,6216,6221,6226,6239,6244,6248,6290,6295,6322,6325,6332,6333,6338,6353,6359,6364,6367,6371,6375,6387,6391,6425,6433,6457,6458,6467,6471,6494,6522,6527,6533,6549,6574,6580,6583,6595,6601,6614,6615,6644,6672,6681,6693,6694,6709,6714,6727,6732,6735,6740,6747,6749,6750,6752,6787,6812,6818,6836,6844,6850,6853,6854,6870,6873,6890,6891,6895,6930,6944,6945,6946,6952,6959,6970,6973,6982,6987,7024,7026,7028,7041,7043,7044,7056,7060,7063,7069,7071,7085,7109,7113,7114,7132,7142,7156,7163,7168,7176,7182,7187,7194,7195,7208,7211,7215,7241,7246,7263,7270,7280,7284,7298,7300,7301,7302,7307,7328,7343,7402,7406,7409,7416,7417,7423,7426,7444,7453,7455,7479,7485,7486,7493,7503,7512,7520,7535,7539,7555,7566,7573,7582,7586,7608,7610,7641,7653,7661,7666,7704,7716,7718,7740,7743,7747,7748,7749,7763,7770,7780,7791,7794,7815,7818,7831,7846,7854,7889,7895,7896,7903,7934,7935,7937,7944,7969,7985,8000,8004,8008,8013,8018,8020,8023,8027,8066,8068,8077,8087,8101,8103,8116,8132,8137,8152,8156,8159,8160,8166,8184,8189,8198,8213,8214,8239,8253,8268,8269,8297,8332,8334,8343,8358,8366,8369,8370,8387,8404,8409,8413,8439,8459,8488,8504,8513,8523,8529,8538,8555,8568,8596,8598,8599,8612,8622,8634,8637,8642,8647,8650,8658,8663,8676,8680,8694,8701,8702,8727,8744,8746,8748,8773,8779,8786,8796,8802,8834,8840,8882,8898,8910,8918,8932,8942,8944,8954,9006,9014,9027,9029,9066,9071,9077,9083,9088,9098,9105,9111,9114,9116,9126,9127,9194,9208,9216,9233,9277,9282,9283,9302,9308,9318,9328,9334,9335,9338,9342,9346,9347,9361,9365,9382,9426,9434,9436,9499,9501,9512,9517,9525,9542,9545,9548,9552,9558,9564,9570,9586,9588,9624,9656,9657,9659,9675,9723,9739,9763,9770,9783,9801,9803,9817,9845,9849,9856,9861,9881,9883,9885,9889,9892,9893,9902,9915,9925,9936,9955,9956,9962,9965,9988,9993,9994";
};
</script>

Test runner

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

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
split
string.split(",");
pending…
split2
var array = [], z = "", l = string.length-1;

for (var c, i = -1; c = string[++i];) {
  if (c === ",") {
    array.push(z);
    z = "";
  } else if (i === l) {
    z += c;
    array.push(z);
  } else {
    z += c;
  }
}
pending…

You can edit these tests or add even more tests to this page by appending /edit to the URL.

Compare results of other browsers

0 comments

Add a comment