, -
if (i % 1000 === 0) {
console.log(i + " " + stopwatch.elapsedMilliseconds + " : " + a.length);
}
. ( , , )
. , , , " " 2000 - node. - - :
[loop max num, unit, 3 resultsmarks results]
70k: [ms] ~ 26k, ~ 25.7k, ~ 26k
72k: [ms] ~ 25.6k, 27k, 25.7k
, , , 10k . , splice 1 , - 1 "", 10 10k-, , . :
var Stopwatch = require("node-stopwatch").Stopwatch;
var stopwatch = Stopwatch.create();
var a1 = [], a2 = [], a3 = [], a4 = [], a5 = [];
var a6 = [], a7 = [], a8 = [], a9 = [], a10 = [];
stopwatch.start();
function fill (arr) {
for (var i = 1 ; i < 10000 ; i++){
arr.push((parseInt(Math.random() * 10000)) + "test");
}
}
fill(a1); fill(a2); fill(a3); fill(a4); fill(a5);
fill(a6); fill(a7); fill(a8); fill(a9); fill(a10);
let removeCount = 0;
function unfill(arr) {
for (var i = 1 ; i < 10000 ; i++){
arr.splice(0,1);
removeCount++;
if (i % 1000 === 0) {
console.log(i + " " + stopwatch.elapsedMilliseconds + " : " + arr.length);
}
}
}
unfill(a1); unfill(a2); unfill(a3); unfill(a4); unfill(a5);
unfill(a6); unfill(a7); unfill(a8); unfill(a9); unfill(a10);
stopwatch.stop();
console.log("End: " + stopwatch.elapsedMilliseconds + " removeCount " + removeCount);
... , 70k 72k - , , ... , , - .
, . 100k (-10) 10 73-74 . , 2d- , , .
.