Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Symbol vs String property square bracket, loop 2
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36
Browser:
Chrome 119
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Symbol
2816764.0 Ops/sec
String
2823161.2 Ops/sec
Symbol sum
2925757.2 Ops/sec
String sum
2959609.8 Ops/sec
Script Preparation code:
var sym = [Symbol("key1"), Symbol("key2"), Symbol("key3"), Symbol("key4"), Symbol("key5"), Symbol("key6"), Symbol("key7"), Symbol("key8"), Symbol("key9"), Symbol("key0")]; var str = ["key1", "key2", "key3", "key4", "key5", "key6", "key7", "key8", "key9", "key0"]; var foo1 = { [sym[0]]: 0, [sym[1]]: 0, [sym[2]]: 0, [sym[3]]: 0, [sym[4]]: 0, [sym[5]]: 0, [sym[6]]: 0, [sym[7]]: 0, [sym[8]]: 0, [sym[9]]: 0, }; var foo2 = { [str[0]]: 0, [str[1]]: 0, [str[2]]: 0, [str[3]]: 0, [str[4]]: 0, [str[5]]: 0, [str[6]]: 0, [str[7]]: 0, [str[8]]: 0, [str[9]]: 0 };
Tests:
Symbol
for(const k of sym) foo1[k] = 1;
String
for(const k of str) foo2[k] = 1;
Symbol sum
let sum = 0 for (const k of sym) sum += foo1[k];
String sum
let sum = 0 for (const k of str) sum += foo2[k];