Having trouble speeding up a reporter

So I had an idea to speed up decimal -> hex conversions by using a lookup table but I'm having problems in making such a reporter

In this project

https://snap.berkeley.edu/snap/snap.html#present:Username=cymplecy&ProjectName=hexConvertorComparision&editMode

there is the original pen library blocks that I'm using as a reference

Then there is my simple lookup version
image

which is 2 times slower - this is due to Snap! having to decode the list reporter values

Then there is one where I use a pre-computed lookup list

image

and that gives me the expected speedup (4 times) over the original

But, then we have the problem that we need to create the global variable if it doesn't exist
hence version (3)

image

But it turns out, that the testing for variable existing takes a long time so this method is not a runner as its 11 times slower! :frowning:

So then I tried (4) in which I test to see if the block has been run before and only try the var creation on its first run

which speeds it up from (3) but is still 2 times slower than the original pen library reporter

At this point, I feel I'm only left with having to include a command block to initialise the global var
image

and I'll just have to include that at the start of any project that uses version (2)

Has anyone got any other ideas I could try (or a completely different fast method of converting to hex?)

FTAOD - No JavaScript wanted :slight_smile:

I've found a simple faster method that doesn't require a global var - put the values into a string and split it to generate the lookup list - much quicker than using the plain list!

image

2 times faster :slight_smile:

I wonder if there is an even faster variation ....

Who knows?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.