r3wp [groups: 83 posts: 189283]
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r3wp

[Profiling] Rebol code optimisation and algorithm comparisons.

PeterWood
2-Jun-2010
[410]
>> time-block [ ] 0,05
== 1.251220703125E-8
Ladislav
2-Jun-2010
[411]
Yes, interesting, so, even though your processor is a bit slower 
than mine, the NOW/PRECISE evaluation is significantly faster
PeterWood
2-Jun-2010
[412]
Couldn't that be influenced by the underlying system calls
Ladislav
2-Jun-2010
[413]
sure
Maxim
2-Jun-2010
[414x3]
I wouldn't be surprised that just about all system calls are faster 
on OSX
my mac mini is a super chitty system HW, but its still faster at 
editing video than PCs four times as capable.
chitty = shitty... hehhe
Ladislav
2-Jun-2010
[417]
Nevertheless, taking into account, that the clock resolution is better, 
it looks like the OSX actually does more (useful) work than Windows 
7
PeterWood
2-Jun-2010
[418]
Out of interest, I ran the same tests in  Windows/XP running under 
Virtual Box:

>> do http://www.fm.tul.cz/~ladislav/rebol/timblk.r
== 1.00330578512397E-2
>>  time-block [now/precise] 0,05
== 7.59124755859375E-7
>> time-block [ ] 0,05
== 7.57351517677307E-9
Ladislav
2-Jun-2010
[419]
hmm, this looks, that the "system clock" are quite inexact in your 
VirtualBox, I guess
PeterWood
2-Jun-2010
[420]
That could well be the case - let me run them again
Ladislav
2-Jun-2010
[421]
I think, that I read somewhere, that system clocks in virtual machines 
may be problematic...
PeterWood
2-Jun-2010
[422]
The times for time-block [] and [now/precise] are quite consistent. 
The time for timblk.r improved to around 9.93E-3.
 

Windows may still have been completing its start-up when I ran the 
very first test.
Ladislav
2-Jun-2010
[423]
Nevertheless, according to the results, your XP is not SP2 or later, 
I would say
PeterWood
2-Jun-2010
[424]
XP SP3
Ladislav
2-Jun-2010
[425]
hmm, surprising, normally you would obtain 15.5 milliseconds as the 
first value...
PeterWood
2-Jun-2010
[426]
I've just run the timblk script another 5 times each time the result 
is ~9.937E-3
Ladislav
2-Jun-2010
[427]
you do not have to run the script, it is the

    tick-time: time-tick 0.05

expression
PeterWood
2-Jun-2010
[428x2]
What initially surprised me was that there did not appear to be a 
significant difference bewteen OS X (native) and XP(VM) with  time-block[now/precise] 
0,05
That certainly doesn't suggest that OS X system calls are faster 
than Windows ones.
Maxim
2-Jun-2010
[430x3]
could be that the motherboard and I/O chips are better integrated 
on OSX which means any access to hardware has less latency.
so... does an XP running on a OSX VM run faster than the same on 
a PC board?  ;-)
(i.e. not using a VM)
PeterWood
2-Jun-2010
[433x2]
I was less surprised that XP(VM) performed time-block [ ] 0,05 about 
1.6 times faster than under OS X (Native) as I suspect that Carl 
is more likely to have better  optimised Rebol on Windows than other 
systems.
Max: As I understand, there is at least a 10 per cent performance 
penalty for running Windows under a VM rather than directly (using 
Bootcamp).
Maxim
2-Jun-2010
[435]
Its also possible that MS compilers are better at optimisation on 
intel CPUs than Apple.
Ladislav
2-Jun-2010
[436x5]
Peter, I obtain the same value when running XP in the VirtualBox:

>> include %timblk.r
== 9.93798449612403E-3
>> time-block [] 0,05
== 7.97957181930542E-9
>> time-block [now/precise] 0,05
== 2.11906433105469E-6
so, the time granularity of XP running in VirtualBox looks smaller, 
than when running natively
funny
PeterWood
2-Jun-2010
[441]
From a quick browse of the Virtual Box User Manual, a VM uses the 
host systems "time stamp counter" by default. There are a number 
of options to change the "guest clock".


It's section 9.10 in the Virtual Box User Manual if you want to take 
a look.
Davide
2-Jun-2010
[442]
>> time-block [now/precise] 0,05
== 2.328125E-6
Gabriele
3-Jun-2010
[443x4]
>> time-block [now/precise] 0,05
== 2.43203125E-5
>> time-block [now/precise] 0,05
== 1.526171875E-5
>> time-block [now/precise] 0,05
== 2.44140625E-5
>> time-block [now/precise] 0,05
== 2.42890625E-5
>> time-block [now/precise] 0,05
== 2.4203125E-5
>> time-block [now/precise] 0,05
== 2.4265625E-5
>> time-block [] 0,05
== 1.11503601074219E-8
>> time-block [] 0,05
== 1.11885070800781E-8
>> time-block [] 0,05
== 1.11618041992188E-8
>> time-block [] 0,05
== 1.12886428833008E-8
Max: scratch your theory, this is Linux running on an iMac 24"
(btw, i guess Linux is doing timezone conversion in the time system 
calls, while osx is not, and that would explain the huge difference 
in speed.)
BrianH
4-Jun-2010
[447]
Steeve, could you submit your CureCode #574 DP function to DevBase? 
Or can I? Good work, and it uses well features introduced to R3 since 
DP was originally written. We would do well to have this function 
:)
Steeve
4-Jun-2010
[448]
As you wish Brianh
Maxim
27-Jan-2011
[449]
some things are stunningly non-obvious when it comes time to optimize 
REBOL


>> a: 1x1 b: 10x10 s: now/precise loop 1000000 [second b - a] difference 
now/precise s
== 0:00:00.5


>> a: 1x1 b: 10x10 s: now/precise loop 1000000 [b/y - a/y] difference 
now/precise s
== 0:00:00.969
Henrik
27-Jan-2011
[450]
so, pair refinements are slow?
Maxim
27-Jan-2011
[451x2]
all path access is slow...but I woudn't have thought that using a 
series function and multiplying both values in the pair would be 
twice as fast!
in my mind it would have been roughly equivalent.
Henrik
27-Jan-2011
[453]
that's very interesting for DRAW blocks. I wonder if R3 has the same 
issue.
Maxim
27-Jan-2011
[454x3]
just tried it... A100

in R3 they *are* roughly equivalent  :-)

in fact in R3 the second version is ~ 10% FASTER  !
so, claims that the path access is faster in R3 seems to be true 
across the board
btw the first version is exaclty the same speed as in R2, on my system.
Steeve
27-Jan-2011
[457x2]
I don't use first, second, third .... anymore in R3.
when I have the choice, indeed
Maxim
27-Jan-2011
[459:last]
yeah, its much easier to read.  I only use first/second in R2 because 
their faster.