Thanks Kem. I ran a few tests on my MacBook Pro (Core i5 2,53 GHz, 8 GB RAM, SSD), both with a script and code:
Script:
#pragma BackgroundTasks False
#pragma BoundsChecking False
#pragma NilObjectChecking False
dim startms, totalms as Double
startms = Microseconds
dim i as integer
for i = 0 to 1000000000
next i
totalms = Microseconds - startms
print Str( totalms )
Code:
#pragma BackgroundTasks False
#pragma BoundsChecking False
#pragma NilObjectChecking False
dim startms, totalms as Double
startms = Microseconds
dim i as integer
for i = 0 to 1000000000
next i
totalms = Microseconds - startms
MsgBox Str( totalms )
IDE:
Script: 0.0500488
Code: 32.759,507
build:
Script: 0.0570068
Code: 3.015,140
Makes XojoScript seem fast, BUT:
Doing some actual work in the loop (using less loops):
Script:
#pragma BackgroundTasks False
#pragma BoundsChecking False
#pragma NilObjectChecking False
dim startms, totalms as Double
startms = Microseconds
dim s as string
s = "K1K2K3K4K5K6K7K8K9K10"
dim i as integer
for i = 0 to 1000000
s = ReplaceAll( s, "K", "K " )
s = ReplaceAll( s, "K ", "K" )
next i
totalms = Microseconds - startms
print Str( totalms )
Code:
#pragma BackgroundTasks False
#pragma BoundsChecking False
#pragma NilObjectChecking False
dim startms, totalms as Double
startms = Microseconds
dim s as string
s = "K1K2K3K4K5K6K7K8K9K10"
dim i as integer
for i = 0 to 1000000
s = ReplaceAll( s, "K", "K " )
s = ReplaceAll( s, "K ", "K" )
next i
totalms = Microseconds - startms
MsgBox Str( totalms )
I also tried it with the ReplaceAllB which I expected to be faster but surprisingly for me using ReplaceAllB is slower:
IDE:
Script: 6,166,837.796
Code: 6.502.094,354
ScriptB: 10.207.051,002
CodeB: 10.899.761,705
build:
Script: 6.292.978,685
Code: 6.351.852,240
ScriptB: 10.585.430,674
CodeB: 10.614.094,305
No difference between Script and Code.
Seems the reason it is so fast might be that the optimization is to completely delete the empty loop.