New games every week!
JSE - Optimising Again! Blog
20th July 2021
Got another nice increase in speed, this morning.

-=-=-

I previously wrote a script that tested various methods to see which was quicker.
One of the tests compared a single giant switch:case vs a series of smaller switch:cases, wrapped in a switch:case..

That is..

switch (1/100) {
case 1
...
case 100
}


vs

switch (1/10) {
case 1
switch (1/10) {
case 1-1
...
case 1-10
}
case 2
switch(1/10) {
case 2-1
...
case 2-10
}
}

and so on..

Essentially breaking the giant switch into lots of little switches.

My test script did a massive loop of these and timed which one turned out to be faster.
I tested on all of the browsers I could, and found that one giant switch was ALWAYS faster than jumping through hoops and having multiple nested switches.
So I DEFINITELY didn't go down that route, and instead kept one giant switch.


This morning, I booted up my old Windows laptop and found it was still running the previous None-Chromium version of Edge, which is great, because that version has some lovely debug tools.
I ran the site on that, and the first thing it flagged up was that the giant switch couldn't be optimised.
hmmm..
So, I set about splitting it up, in exactly the way that I'd previously tested to be "the slower method", and gave it a try.


Well, what do you know..

Lesson of the day : Don't trust your tests!!
Views 101, Upvotes 16  
Jse , Optimising
New games every week!
Site credits : This was all done by Jayenkai
(c) Jayenkai 2023 and onwards, RSS feed 5

Blog - JSE - Optimising Again! - AGameAWeek