Optimization is usually not so much a question of writing style but of programming style. Complex operations can often be simplified and choices can be made in the parameters of the program flaw that can make a big difference.
Unless your program is made exclusively of instr test, do not expect a miracle from one notation over another. 0.05% is a measurable difference, but in practical terms, it makes no difference. What is important is not to measure what the changes imply and make an informed decision, rather than to go on a whim.
You mention mathematical routines. There may be more room from improvement. Let alone in using XojoScript over the regular code, since tests do show very sensible differences.
Here is what I posted in https://forum.xojo.com/14123-xojo-benchmark
As you can read, the difference is approximately 50%. I would not call that negligible, and note that the code is exactly the same.
In the same thread, Sam Rowlands used the same code on a Mac and went down to 0.24 seconds…
— Posted on July 24th, 2014 —
Xojo has not said its last word. There are actually two compilers that can execute the benchmark code. The regular one used by the IDE, and the LLVM compiler used for the XojoScript class.
I used the very same code as posted by Djamel in a XojoScript control source, except I used PRINT in the last line like so
[code]#pragma BackgroundTasks False
Dim x As double
Dim y As Double
Dim i As int32
Dim t As double
x = 1
y = 1.000001
t = Microseconds
For i = 1 To 100000000
x = x * y
Next
t = (microseconds - t)/1000000
Print “X= " + str(x) + " T= " + format(t,”#0.00")+ " Sec"
[/code]
And placed msgbox msg
in the Print event of XojoScript1.
On my now old PC, a built app gives :
- Regular code : 0.94 s.
- XojoScript : 0.48 s
It is already way below 0.66 s. If I apply the same ratio to Djamel benchmark, which is probably the time he would get from the same code on his machine, that would give a whopping 0.35 s. Almost half VB6 time
For these kinds of mathematical operations, at least, and within the limits of the exercise, XojoScript could be a good tip to accelerate code.
Here is the project in case you want to try : benchmark.xojo_binary_project