Version française
Home     About     Download     Resources     Contact us    
Browse thread
Correct way of programming a CGI script
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: skaller <skaller@u...>
Subject: Re: [Caml-list] Correct way of programming a CGI script
On Tue, 2007-10-09 at 08:21 +1000, Erik de Castro Lopo wrote:
> skaller wrote:

> While I agree that yes, it is possible to write slow code in Ocaml
> (or any other language), I suspect that idiomatic Ocaml string handling
> compiled to a binary is just as fast if not faster than Java/Perl/Python/
> Ruby/PHP/whatever.

Fraid not. Python eats Ocaml alive. Python:

s= "a"
x = ""
for i in xrange(0,10000000):
  x = x+s
print "done"

Time: 6 seconds. Without optimisation switched on.

Ocaml:
let x = ref "";;
let  s = "a";;
for i = 0 to 100000 do
  x:= !x ^ s
done;;
print_endline "done";;

Time: 4.5 seconds.

Notice one TINY difference ... Ocaml is processing only 100K strings.
Python is processing 10 MILLION strings in about the same time.

I cannot measure Ocaml's performance when the number is increased
to even 1 million because I have run out of coffee.


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net