[tw5] Re: Interesting test for unique string processing

2021-01-01 Thread PMario
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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/a26cc813-caaa-40ab-899c-1f852dd2fafen%40googlegroups.com.


[tw5] Re: Interesting test for unique string processing

2020-12-29 Thread TW Tones
Hi,

If you are proposing this be used in the core or such perhaps it would be 
better to raise this in the developer discussion's. Since as a rule 
Javascript is not native in User interface but provides modules and plugins.

https://github.com/Jermolene/TiddlyWiki5/discussions

tones

On Wednesday, 30 December 2020 at 11:36:08 UTC+11 arle...@gmail.com 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 tiddlywiki+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tiddlywiki/544b6a9c-9a1e-4f4b-95f4-94bd5274097cn%40googlegroups.com.