var object_n = {};
object_n["p1"] = 1;
object_n["p2"] = 2;
object_n["p3"] = 3;
object_n["p4"] = 4;
object_n["p5"] = 5;
object_n["p6"] = 6;
object_n["p7"] = 7;
object_n["p8"] = 8;
object_n["p9"] = 9;
var array_n = [];
array_n.push("p1",1);
array_n.push("p2",2);
array_n.push("p3",3);
array_n.push("p4",4);
array_n.push("p5",5);
array_n.push("p6",6);
array_n.push("p7",7);
array_n.push("p8",8);
array_n.push("p9",9);
var object_s = {};
object_s["p1"] = "1";
object_s["p2"] = "2";
object_s["p3"] = "3";
object_s["p4"] = "4";
object_s["p5"] = "5";
object_s["p6"] = "6";
object_s["p7"] = "7";
object_s["p8"] = "8";
object_s["p9"] = "9";
var array_s = [];
array_s.push("p1","1");
array_s.push("p2","2");
array_s.push("p3","3");
array_s.push("p4","4");
array_s.push("p5","5");
array_s.push("p6","6");
array_s.push("p7","7");
array_s.push("p8","8");
array_s.push("p9","9");
var array_bn = new Array(10);
var i = 0;
array_bn[i++] = ["p1", 1];
array_bn[i++] = ["p2", 2];
array_bn[i++] = ["p3", 3];
array_bn[i++] = ["p4", 4];
array_bn[i++] = ["p5", 5];
array_bn[i++] = ["p6", 6];
array_bn[i++] = ["p7", 7];
array_bn[i++] = ["p8", 8];
array_bn[i++] = ["p9", 9];
var array_bs = new Array(10);
var j = 0;
array_bs[j++] = ["p1", "1"];
array_bs[j++] = ["p2", "2"];
array_bs[j++] = ["p3", "3"];
array_bs[j++] = ["p4", "4"];
array_bs[j++] = ["p5", "5"];
array_bs[j++] = ["p6", "6"];
array_bs[j++] = ["p7", "7"];
array_bs[j++] = ["p8", "8"];
array_bs[j++] = ["p9", "9"];
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
dynamic create object integer value | |
dynamic create array integer value | |
dynamic create object string value | |
dynamic create array string value | |
buffered array integer values | |
buffered array string value |
Test name | Executions per second |
---|---|
dynamic create object integer value | 21422094.0 Ops/sec |
dynamic create array integer value | 2262831.8 Ops/sec |
dynamic create object string value | 21086998.0 Ops/sec |
dynamic create array string value | 2206855.0 Ops/sec |
buffered array integer values | 2024264.0 Ops/sec |
buffered array string value | 2031782.8 Ops/sec |
Let's break down the benchmark and its various components.
Benchmark Definition
The benchmark is defined in JSON format, which represents four different approaches to dynamically creating objects or arrays:
{}
syntax, where each property is assigned a value.[]
syntax, where elements are pushed onto the array using the push()
method.Options Compared
The benchmark compares the performance of these five approaches:
Latest Benchmark Result
The latest results show the performance of each approach on a specific browser (Chrome 51) running on a Windows platform. The results are measured in executions per second, which indicates how many times the code is executed per second.
Here's a summary of the results:
Test Name | Executions Per Second |
---|---|
Dynamic Object Integer Value | 21422094.0 |
Dynamic Object String Value | 21086998.0 |
Dynamic Array Integer Value | 2262831.75 |
Dynamic Array String Value | 2206855.0 |
Buffered Array Integer Values | 2024264.0 |
Buffered Array String Value | 2031782.75 |
Interpretation
The results suggest that:
Keep in mind that these results may not generalize to other browsers or platforms. Additionally, the performance difference between these approaches can be influenced by various factors, such as the specific use case, data size, and system resources.