Hi Arlen,
It would be interesting, what you try to prove here?
Accessing big arrays with a loop is probably always slower than accessing
an object element by name. The biggest difference probably is memory
consumption.
-m
On Wednesday, December 30, 2020 at 1:36:08 AM UTC+1 Arlen Beiler wrote:
> 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/a26cc813-caaa-40ab-899c-1f852dd2fafen%40googlegroups.com.