I am fairly devastated because I believe I reach a point when thunkable is fundamentally incapable to fulfill my quest.
I am trying to perform a 4-layer nested loop combination that aims to calculate a number. The initial data looked like this:
This is an election simulation app. For each county, each racial group, each candidate, there will be a sentiment for each factor, indicating that person’s support on a particulat front; for each county, each racial group, there will be an importance, indicating how each factor is valued; there are also enthusiasm attached to each county serving as turnout modifier.
The task is simple, I need to multiple sentiment, enthusiasm and importance together, then multiply accordingly with demographic, TLDR, The center line in the loop will be performed 3000 (counties) x 28 (stratifying groups) x 7 (factors) x 3 (candidates) = around 2 million runs. Initially the center line was a math formula, but I replaced it as a mere simple “set X to 0” to test out its speed.
Unfortunately for me, without the need to run 2 million times, simply running a 5 county example JSON file, which only contains 3,333 runs, takes 5.9 seconds. Obviously the speed is device dependent, but I feel like averaging 600 multiplying task/ sec is not optimal for a platform that I continuously paid for around two years and spent countless hours working on this one project.
Please refer to the picture below for seeing my block:
I am very experienced in using thunkable, so I probably have already used all the known tricks on the table. For example, I do know “Set var to var+x” is FASTER than
“Change var by x”, so in this loop I used the latter; I also know that procedural blocks are considerably slower than direct using blocks; and that stored variable is slower than app variable.
I even know that “wait 0 second” is a terrible thing to use in a loop because it will hundred or thousand fold increase the time it takes, as 0 second actually eats up a few milliseconds.
At this point I am dejected and call for help to see if anyone can help me on optimizing my code, although I am generally convinced that this is the edge of power of thunkable, or my hardware. (I am using IPAD MINI 6THgen and IPhone 15 pro for reference.)