From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 80FFCBB84 for ; Mon, 8 May 2006 23:31:04 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id k48LV3IP017781 for ; Mon, 8 May 2006 23:31:03 +0200 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id XAA18046 for ; Mon, 8 May 2006 23:31:02 +0200 (MET DST) From: artboreb@netscape.net Received: from imo-d01.mx.aol.com (imo-d01.mx.aol.com [205.188.157.33]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k48LV1SL010707 for ; Mon, 8 May 2006 23:31:02 +0200 Received: from artboreb@netscape.net by imo-d01.mx.aol.com (mail_out_v38_r7.5.) id g.c2.14218e83 (22683) for ; Mon, 8 May 2006 17:30:58 -0400 (EDT) Received: from mblkn-m05 (mblkn-m05.mblk.aol.com [64.12.170.69]) by air-in04.mx.aol.com (vx) with ESMTP id MAILININ44-589b445fb8921c6; Mon, 08 May 2006 17:30:58 -0400 Date: Mon, 08 May 2006 17:31:18 -0400 Message-Id: <8C840FDE0706B00-1A64-90ED@mblkn-m05.sysops.aol.com> X-MB-Message-Source: WebUI X-MB-Message-Type: User Received: from 201.214.184.142 by mblkn-m05.sysops.aol.com (64.12.170.69) with HTTP (WebMailUI); Mon, 08 May 2006 17:31:18 -0400 X-Mailer: Netscape WebMail 17673 Subject: What kind of sort do Array.sort ? Content-Type: text/plain; charset="us-ascii"; format=flowed MIME-Version: 1.0 To: caml-list@inria.fr X-AOL-IP: 64.12.170.69 X-j-chkmail-Score: MSGID : 445FB895.000 on nez-perce : j-chkmail score : X : 0/20 1 X-Miltered: at concorde with ID 445FB897.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 445FB895.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; toying:01 compiler:01 ocaml:01 emits:01 ocaml:01 timings:01 ocamlopt:01 -unsafe:01 unix:01 cmxa:01 gcc:01 usr:01 usr:01 lib:01 argv:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=MSGID_FROM_MTA_HEADER, NO_REAL_NAME autolearn=disabled version=3.0.3 Dear Calmers, Toying with a compiler (builded in Ocaml of course) of a language I developed which emits C code I've written some bemchmarks to test it. For my surprise the same program written in Ocaml lasts almost 6 times. It's about sorting an integer array, the timings are: Ocaml (ocamlopt -unsafe unix.cmxa qc.ml -o qc) real 1m10.727s user 1m9.074s sys 0m0.001s Mine (gcc -I /usr/local/include -O3 -s x12.ao.c -o x12 /usr/local/lib/libgc.a -lpthread) real 0m18.536s user 0m18.018s sys 0m0.002s times to take sorting 1000000 an array of 100 random ints the Ocaml code is open Format let _ = if Array.length Sys.argv = 2 then begin Random.init (Unix.getpid ()); let a = Array.make (int_of_string Sys.argv.(1)) 0 in for i = 0 to 1000000 do for j = 0 to Array.length a - 1 do a.(j) <- Random.bits () done; Array.sort (fun x y -> if x > y then 1 else if x = y then 0 else -1) a done; for i = 0 to 99 do printf "%010d\n" a.(i) done end I dont attach the C code emitted because is about 280 lines long, my language (for the courious) "ao.ao" INC [Array Int Int] # RAPIDO RECURSIVO [(a l r) l r a l -> (hl hr p) [l r] [l r >=] [l] [ [r] [a r -> p >= l r < & !] [r] [r 1 -] TREC (r) l l r =/= [a a r -> l <<- 1 +] IFTE (l) [l] [a l -> p <= l r < & !] [l] [l 1 +] TREC (l) l r l r =/= [a a l -> r <<- 1 -] IFTE] TREC (l) a p l <- hl l < [hl l 1 - Qsort] IFTE hr l > [l 1 + hr Qsort] IFTE ] Qsort FUN ARGC 2 = [ Getpid Srand [;Int] ARGV 1 -> Atoi MAKE Length 1 - (a n) [[(i) a Rand i <<-] 0 n Upto a 0 n Qsort X-] 1000000 Times a [?n] Fold #[] [Rand "%010d" FMT] Rnd_strnum FUN ] IFTE Best regards, Arturo Borquez ___________________________________________________ Try the New Netscape Mail Today! Virtually Spam-Free | More Storage | Import Your Contact List http://mail.netscape.com