This Question is Answered

1 "correct" answer available (5 pts) 10 "helpful" answers available (3 pts)
8 Replies Last post: Aug 25, 2008 3:29 PM by Duke

Is Curl faster than JavaFX?

Aug 25, 2008 1:46 PM

Click to view RMH's profile Curl RMH 45 posts since
Feb 17, 2008
Chris Oliver reciently posted (updated here) a Takeuchi benchmark comparing JavaFX to ActionScript. He compared JavaFX running in the Hotspot server vm and client vm against ActionScript running in the Tamarin JavaScript VM. I would love to see us run Curl on this benchmark just for fun.

I have a couple of problems, however. First I can't figure out for the life of me what his benchmark numbers mean (e.g. real 0m58.587s?). Second, my tak program isn't working - it keeps telling me that my recursive procedure, 'tak', "may fall off the end without executing a 'return' "

Here is the code that I wrote:


{curl 6.0 applet}
 
{define-proc {tak x:int, y:int, z:int}:int
    {if y >= x then
        {return z}
     else
        {tak
            {tak {value x - 1}, y, z},
            {tak {value y - 1}, z, x},
            {tak {value z - 1}, x, y}
        }       
    }
}
 
{count-cycles
    {for i=1 to 1000 do
        {tak 24, 26, 8}
    }
}
 


It would be great if folks in the community could help out with this.


  • First how do you interpret the benchmarks Chris Oliver presents?
  • Second what can be done to my code my code to make it work?
  • Third, once the code is working, what can be done to make it as fast as possible?
Click to view wbardwell's profile Curl wbardwell 46 posts since
Oct 31, 2007
1. Re: Is Curl faster than JavaFX? Aug 25, 2008 1:16 PM

The code from that is closest to the following:


 
 {curl 6.0 applet}
 
{define-proc {tak x:double, y:double, z:double}:double
    {return
        {if y >= x then
            z
         else
            {tak
                {tak x - 1, y, z},
                {tak y - 1, z, x},
                {tak z - 1, x, y}
            }
        }
    }
}
 
{def start = {DateTimeData}}
{for i=1 to 100 do
    {tak 24, 16, 8}
}
{start.elapsed}

The numbers that they are listing are the output from the 'time' command on a unix style system.

So 'real' is wall clock time, user and system are the amount of time that was spend in the OS verses in the user code (sort of.)cy

To be able to accurately compare those code samples with Curl RTE ones you need to run all of the tests on the same machine, since the speed of this is heavily tied to the CPU that is running it.

Also running it as an applet makes the Curl language versions slower, because it is going to do graphics and such. If you run it as a script, with no output, that is a fairer comparison

(Run the 'curl' or 'curl-aca' binary on a file with a script herald.)

cycle-count is useful for doing optimizations on some machines, but it doesn't directly translate into real world time.

Click to view wbardwell's profile Curl wbardwell 46 posts since
Oct 31, 2007
2. Re: Is Curl faster than JavaFX? Aug 25, 2008 1:23 PM
in response to: wbardwell
Also note that the way that he was running that meant that the times do not include time use for compilation, but was (assuming that any JVM caches were cleared) charged for JITing Java byte code. There is no equivilent way to run stuff in the Curl RTE, but presumably making that code be a package that was package cached (compiled and saved as machine code, and then run for timing a second time) would be similar, but give the Curl RTE an advantage. If you just run it as an applet or script body then the compilation time is included in the timing.
Click to view RMH's profile Curl RMH 45 posts since
Feb 17, 2008
3. Re: Is Curl faster than JavaFX? Aug 25, 2008 1:33 PM
in response to: wbardwell
Wow, quick reply. I changed my program to have the script herald and I tried to run it but I got an error


 
richard-monson-haefels-macbook-pro:Desktop rmonson$ curl tak.xcurl
curl: (6) Couldn't resolve host 'tak.xcurl'

What am I doing wrong? I can't find documentation for running curl or curl-aca. I'm running on a Mac OS X 10.4

Click to view dmccrae's profile Curl dmccrae 20 posts since
Oct 10, 2007
4. Re: Is Curl faster than JavaFX? Aug 25, 2008 1:48 PM
  • Both sides of the conditional need to return.
  • The only way I know to interpret the results is run each variant on same machine
  • Other than declaring types, which you have done, its as fast as it can be.
  • If you're running debuggable, its often slower, so check the control panel debigger pane

{curl 6.0 applet}
 
{define-proc {tak x:int, y:int, z:int}:int
    {return
        {if y >= x then
            z
         else
            {tak
                {tak x - 1, y, z},
                {tak y - 1, z, x},
                {tak z - 1, x, y}
            }
        }
    }
}
 
{value
    def n = 1000
    def t = {DateTimeData}
    {for i = 1 to n do
        {tak 24, 16, 8}
    }
    {text Ran {value n} iterations in {t.elapsed}}
}

{text Machine cycles per iteration: }
{count-cycles num-iterations = 1000,
    {tak 24, 16, 8}
}


I get this output on a 2.26Ghz Pentium

Ran 1000 iterations in 25.99s

Machine cycles per iteration: 51016486

Message was edited by: dmccrae - now uses correct arguments {tak 24, 16, 8}
Click to view RMH's profile Curl RMH 45 posts since
Feb 17, 2008
5. Re: Is Curl faster than JavaFX? Aug 25, 2008 1:40 PM
in response to: dmccrae

Doug,

Shouldn't your last part be "num-interations 100000" rather than "1000". You run it throught the for loop 100,000 times but you only cycle it 1000 times. What am I missing.


Also, what do you think of the idea of changing the hearld to "package" and running it with the curl or curl-aca command line so that you don't get penalized for browser time? Is that fair to JavaFX and ActionScript?

Click to view RMH's profile Curl RMH 45 posts since
Feb 17, 2008
6. Re: Is Curl faster than JavaFX? Aug 25, 2008 1:44 PM
in response to: RMH
It looks like Chris Oliver did a follow up post which provides new numbers


http://blogs.sun.com/chrisoliver/category/JavaFX

Click to view dmccrae's profile Curl dmccrae 20 posts since
Oct 10, 2007
7. Re: Is Curl faster than JavaFX? Aug 25, 2008 2:14 PM
in response to: RMH
I do not see a significant difference from packaging.

By the way, my original post had the wrong arguments to the test,
but its now corrected to 24, 16, 8. Sorry about that.
Click to view Duke's profile Curl Duke 154 posts since
Oct 17, 2007
8. Re: Is Curl faster than JavaFX? Aug 25, 2008 3:29 PM
in response to: RMH
Richard, I think the error you are getting about "couldn't resolve host" means that you are running the cURL program instead of Curl, because Curl is not on the Unix search path for command lines. You would have to find the directory where Curl is installed on your Mac and explicitly put the full pathname in front of curl or curl-aca. Follow the link from the Curl shortcut in your Applications folder, I think that leads to some Library directory. Or just do a spotlight search for curl-aca.