Here is an interesting test to see which method of unique strings is faster
in Javascript. Paste it into your browser console in a new tab and see
what happens.

for (let r = 0; r < 100; r++) {
let test = Math.random().toExponential(10);
let count = 1000;
let test1 = {};
let test2 = [];
console.time("test 1");
for (let i = 0; i < count; i++) {
let item = test + "" + i;
if (!test1[item]) test1[item] = true;
}
console.timeEnd("test 1");
console.time("test 2");
for (let i = 0; i < count; i++) {
let item = test + "" + i;
if (test2.indexOf(item) === -1) test2.push(item);
}
console.timeEnd("test 2");
}

-- 
You received this message because you are subscribed to the Google Groups 
"TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/CAJ1vdSQqnSJG8iZhd-QizDA%3D2OMXq5ecAi3jLLVuY-5yQDLsTQ%40mail.gmail.com.

Reply via email to