• Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

World: r4wp

[#Red] Red language group

Rebolek
15-Jul-2012
[686]
Thanks, it's getting late, I better should left testing for tommorrow 
:)
DocKimbel
15-Jul-2012
[687x2]
I've located the cause of bug #220, you should have a fix when you'll 
wake up. ;-)
Fix for issue #220 pushed.
Rebolek
16-Jul-2012
[689x2]
Wow, that' was fast! :)
I've added information about my machine to #219 (no gcc info, as 
it doesn't have gcc installed).
Rebolek
17-Jul-2012
[691]
Doc, another float! problem found (#221).
Rebolek
18-Jul-2012
[692]
Can anybody check this code? https://gist.github.com/3135678

It's not a bug, but I wonder why the obviously more complex sine-osc 
is cca 50% faster than square-osc. These are the results I get on 
my machine:

sine-osc time:  1068
square-osc time:  1790
PeterWood
18-Jul-2012
[693]
Are you running on OSX?
Rebolek
18-Jul-2012
[694]
Windows
PeterWood
18-Jul-2012
[695x2]
If I remember correctly, the Windows clock function is a bit different 
from the LibC one.
I use Query PerformnceCounter in Windows in my Date-Time lib.
Rebolek
18-Jul-2012
[697]
So you think that the 50% speed difference between these two functions 
is due to Windows clock?
Pekr
18-Jul-2012
[698x3]
Windows clock is bitch :-)
http://www.codeproject.com/Articles/1236/Timers-Tutorial
There's even some mention of the Amiga in the above article comments, 
and even Carl liked it, IIRC :-)
Rebolek
18-Jul-2012
[701]
Well the timing is consistently more or less same and square-osc 
is always about 50% slover than sine-osc. I think that it's not caused 
by Windows timing.
Kaj
18-Jul-2012
[702x3]
Beats me. It looks OK
It's true, though, that process-time is currently a primitive function
Have you tried moving the one execution before the other, to make 
sure it's not some process anomaly?
Rebolek
18-Jul-2012
[705]
Yes.
Kaj
18-Jul-2012
[706x2]
Seems like a fairly sound timing, then
You could try increasing the loops another tenfold
Rebolek
18-Jul-2012
[708x3]
Yes, I also tried putting more loops there (for example sine sine 
square square sine square), but the timing is always consistent.
Loop increased tenfold:

sine-osc time:  10576
square-osc time:  22034
Switched order:

square-osc time:  17441
sine-osc time:  15318
Kaj
18-Jul-2012
[711x4]
There's a lot of variation in the results for such a long loop, so 
it does point to timer instability
I remember that most platforms account real scheduler timeslices 
in this function, while some basically take wall clock time
I think the latter was Windows, so that would make ik very susceptible 
to anything else going on in the machine
Still, the difference between the Red functions is mysterious. I 
think Nenad would have to analyse that
Rebolek
18-Jul-2012
[715]
It isn't causing any problems, I'm just curious why it happens.
Kaj
18-Jul-2012
[716x5]
Yes, it's a good point
Syllable Server (Linux):
bash-4.0# ./test                                                 
                                                                 
           
sine-osc time: 5330000
square-osc time: 2760000
bash-4.0# ./test 
sine-osc time: 5450000
square-osc time: 2830000
That's stable scheduler timing. Problem solved, I guess, but not 
a good verdict for Windows
There could still be a performance issue on Windows
Rebolek
18-Jul-2012
[721]
These numbers look like something I expected :)
DocKimbel
18-Jul-2012
[722x3]
These are the timings on my Win7/Corei7 box:

sine-osc time:   1003
square-osc time: 939

sine-osc time:   997
square-osc time: 938

sine-osc time:   997
square-osc time: 952

-- reversed order --

square-osc time: 938
sine-osc time:   995

square-osc time: 939
sine-osc time:   996

square-osc time: 939
sine-osc time:   996
(ran the tests 3 times for each order)
Do you run Windows virtualized?
Rebolek
18-Jul-2012
[725]
No
DocKimbel
18-Jul-2012
[726]
I had a quick look at the code paths of both generated `square-osc` 
and `sin-osc` functions, all seems fine. But I do concurr that the 
results are not intuitive. I guess that the relative performances 
in such case are just too hardware-dependent.
Rebolek
18-Jul-2012
[727]
Probably yes.
DocKimbel
21-Jul-2012
[728]
Rebolek: issue #221 has been fixed.
Rebolek
22-Jul-2012
[729x5]
Doc, I can still reproduce it with this code:

x: 0.0
x: either x > 0.0 [x][0.0 - x]
print [x lf]

If I assign the result to 'y instead of 'x, it works.
Ah, that's not the reason. It happens when the condition is FALSE 
and FALSE block ends with expession.So the above code works for x 
= 1.0
When I change order, the code works:

x: 0.0
x: either x <= 0.0 [0.0 - x][x]
print [x lf]
But this also throws 11: float stack check error when used in function:

fabs: func [x [float!] return: [float!] ][
	either x < 0.0 [0.0 - x][x]
]
print [fabs -3.14 lf]
Final workaround :)

fabs: func [
	x			[float!]
	return:	[float!]
][
	x: either x < 0.0 [0.0 - x][x]
	x
]
print [fabs -3.14 lf]
DocKimbel
22-Jul-2012
[734x2]
Thanks, I will debug that tonight.
Issue fixed.