To answer my own question, if someone else is interested in speeding up certain parts of their projects, I recommend looking into calculating the answers in advance and storing them in tables. Here’s the code from one of my tests:
local mathRad = math.rad local getTimer = system.getTimer local deg2rad = {} for i = 1, 3600 do deg2rad[i] = mathRad(i\*0.1) end local t1, t2 = {}, {} local startTimeT1 = getTimer() for i = 1, 10 do for j = 1, 3600 do t1[#t1+1] = mathRad(j) end end local endTimeT1 = getTimer()-startTimeT1 local startTimeT2 = getTimer() for i = 1, 10 do for j = 1, 3600 do t2[#t2+1] = deg2rad[j] end end local endTimeT2 = getTimer()-startTimeT2 print("Duration by using math.rad: "..endTimeT1) print("Duration by checking table: "..endTimeT2)
I tried the following code on my computer, as well as on two mobile devices. On my computer, the results varied greatly, but checking the table was faster every time. The results varied from checking the table being 1.1 times faster to 1.9 times faster. On my mobile devices, the were instances were checking the table was even 4 to 5 times faster.
So, it would seem that calculating the answers in advance can provide a great boost in performance, but it comes at the expense of accuracy and increased size on the disk.