-
Notifications
You must be signed in to change notification settings - Fork 0
Performance comparison of loops
Julius Paffrath edited this page Sep 11, 2018
·
5 revisions
In this chapter I will share some performance comparison results. I was interested how runtime performance is influenced by different ways to run code multiple times in jask.
Generally there are three different options to achieve loops in jask: run loops, while loops and the call operator. The following samples all produces the same results:
run i from 0 to 1000000 with i plus 1
printLine(i)
endrun
store 0 in i
while i smaller 1000000
printLine(i)
increment i
endrun
store 0 in i
function run()
printLine(!i)
increment !i
end
call run() 1000000 times
To get more precise results, I executed all three ways on the same machine to a counter of 1.000.000. Every execution ran in its own context. The execution times are the arithmetic averages of ten executions:
- run loop: 19.551 seconds
- while loop: 17.984 seconds
- call operator: 28.125 seconds
As you might expect, the call operator was the slowest, because function executions are very expensive. The while loop was slightly faster than the run loop.
- Home
- Getting started
- Control flow
- Functions
- List variables in jask
- Dictionary variables in jask
- Structs in jask
- Convert variables
- Internal Functions
- The access operator
- Callbacks in jask
- Modules
- Internal Modules
- The jask standard library jcore
- Using CMD arguments in jask
- Nested function calls
- Functions inside functions!
- Modules inside functions!
- Performance comparison of loops