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.

Ladislav
2-Jun-2010
[388]
this does not have anything in common with resolution, this is about 
interpretation speed, Max
Maxim
2-Jun-2010
[389]
and how do you measure the execution?  by accessing some form of 
timing or time information.
Ladislav
2-Jun-2010
[390]
so what?
Maxim
2-Jun-2010
[391]
if OSX has ten times the resolution, it will give you the impression 
that its ten times faster.
Ladislav
2-Jun-2010
[392]
wrong
Maxim
2-Jun-2010
[393]
how so?
Ladislav
2-Jun-2010
[394x6]
Of course, the evaluation time of NOW/TIME may be operating system 
dependent, but it is still interpretation time (of the above expression)
Peter, how about this one?

>> time-block [] 0,05
== 7.80820846557617E-9
Max: "how so?" - I suppose, that you do see, that the TIME-BLOCK 
function is able to measure evaluation time even if it is shorter 
than the system clock resolution?
(the "trick" is pretty simple, everybody knows how to do that, check 
the source)
finding out it is so obvious, I should probably patent the idea, 
shouldn't I?
My system is Windows 7 Business 64-bit, AMD Athlon X2 250 at 3GHz
Rebolek
2-Jun-2010
[400]
>> time-block [] 0.05
== 1.45263671875E-8
Ladislav
2-Jun-2010
[401x2]
Yes, certainly faster
, so, it looks, that the time the system spends in NOW/PRECISE is 
nonnegligible
Maxim
2-Jun-2010
[403]
what does this do in the time-block  while condition?

(3 * tick-time / time)
Ladislav
2-Jun-2010
[404]
adds the relative error possibly caused by clock resolution to the 
figure to make sure we achieve the desired accuracy
Maxim
2-Jun-2010
[405]
I'm curious as to why the resolution is multiplied by 3?
Ladislav
2-Jun-2010
[406]
because we have two measurements, the previous one using two times 
less cycles, i.e. possibly having twice the influence of the resolution
Maxim
2-Jun-2010
[407]
ok makes sense.
Ladislav
2-Jun-2010
[408x2]
:-)
so, I should definitely have it patented ;-)
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
[436x2]
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