caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] novice puzzled by speed tests
@ 2004-01-03 12:57 dolfi
  2004-01-04 16:49 ` Xavier Leroy
  0 siblings, 1 reply; 34+ messages in thread
From: dolfi @ 2004-01-03 12:57 UTC (permalink / raw)
  To: caml-list


Hi everybody,

I'm new to the list, and deeply impressed by the stability and speed of
OCaml, as well as its functional nature. My best congratulations to the
authors!

Toying around with 3.07, I found that ocamlopt.opt -unsafe (on Mandrake
9.1, Pentium 4, 2.4 GHz) actually produces slower code than ocamlopt.opt.
The program in question is a prime generator:

let count = 400000

let ptab =
  let ptab = Array.create count 0 in
  ( ptab.(0)<- 2; ptab.(1) <- 3; ptab.(2) <- 5; ptab );;

let rec loop nr toggle psize =
(   let max = truncate (sqrt (float nr)) in
    let rec floop i =
      if ptab.(i)>max then
        ( ptab.(psize) <- nr;
          loop (nr+toggle) (6-toggle) (succ psize) )
      else if nr mod ptab.(i) = 0 then
        loop (nr+toggle) (6-toggle) psize
      else
        floop (succ i)
    in if psize<count then floop 2 else ()
) in loop 5 2 3;

Printf.printf "prime %d: %d\n" count ptab.(pred count);;

On my box, the corresponding C program (gcc -O3) is slightly slower than
the ocamlopt.opt compiled O'Caml program, but about 25-30% faster than the
-unsafe one:

#include <stdio.h>
#include <math.h>

#define how_many 400000

int main()
{   unsigned int nr = 5, toggle = 2, max, primes_size = 3, i;
    unsigned int primes[how_many];

    primes[0] = 2; primes[1] = 3; primes[2] = 5;
  loop:
    nr += toggle; toggle = 6 - toggle;
    max = sqrt(nr);
    for (i = 2; primes[i] <= max; ++i)
        if (!(nr % primes[i])) goto loop;
    primes[primes_size++] = nr;
    if (primes_size < how_many) goto loop;

    printf("%i\n", primes[how_many - 1]);
    return 0;
}

Of course it's good that range checking increases the speed of programs,
but, being a long-time C user, I'm a little bit puzzled by miracles like
this. I suspected that the sense of the -unsafe flag was inverted, but it
isn't: the -unsafe program dies with SEGV when I deliberately introduce a
range overflow, the safe one gets an exception.

Till soon, Dolfi




-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 34+ messages in thread
* camlp4
@ 2010-02-06  1:16 Andy Ray
  2010-02-06 11:15 ` [Caml-list] camlp4 blue storm
                   ` (3 more replies)
  0 siblings, 4 replies; 34+ messages in thread
From: Andy Ray @ 2010-02-06  1:16 UTC (permalink / raw)
  To: caml-list

Hi,

My project would really benefit from some simple camlp4 syntax
extensions, however, I am put off by the lack of a reference manual
for it.

At the moment I am tempted to go for camlp5 instead - not least
because I was able to work through it's manual and get some examples
working a while back.

The reality is I would prefer to use camlp4 as it appears to the
official ocaml supported way, but can't see how to get into it as a
beginner due to the lack of documentation (and that appears to have
been the case for quite some time now).  What should one do?

Cheers,
Andy


^ permalink raw reply	[flat|nested] 34+ messages in thread
* camlp4
@ 2008-01-18 17:08 Christian Sternagel
  2008-01-18 18:56 ` [Caml-list] camlp4 Nicolas Pouillard
  2008-01-18 19:30 ` Olivier Andrieu
  0 siblings, 2 replies; 34+ messages in thread
From: Christian Sternagel @ 2008-01-18 17:08 UTC (permalink / raw)
  To: caml-list

When using `camlp4o -parser Camlp4ListComprehension' as preprocessor,
is the resulting code the naive translation, like in,

 [(x, y) | x <- xs, even xs, y <- ys]

=>

 List.flatten (
  List.map (fun x -> List.map (fun y -> (x, y)) ys) (List.filter even xs)
 )

or is there an optimization in order to avoid appends and minimize the
number of cons?

cheers

christian


^ permalink raw reply	[flat|nested] 34+ messages in thread
* [Caml-list] -unsafe and camlp4
@ 2003-07-08 12:49 "Dmitry Bely" 
  2003-07-08 13:38 ` Xavier Leroy
  0 siblings, 1 reply; 34+ messages in thread
From: "Dmitry Bely"  @ 2003-07-08 12:49 UTC (permalink / raw)
  To: caml-list

Can two things live together? When I run ocamlopt -unsafe -pp "camlp4 ..." ..., compiler prints warning and -unsafe seems to be ignored. Am I doing something wrong?

-- Dmitry Bely

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 34+ messages in thread
* [Caml-list] camlp4
@ 2003-06-10 14:22 Pierre CHATEL
  0 siblings, 0 replies; 34+ messages in thread
From: Pierre CHATEL @ 2003-06-10 14:22 UTC (permalink / raw)
  To: caml-list

Hello, i'm kinda new to the list, so i hope my newbie questions will 
not disturb everyone :))

So, i was wondering if there were something like Scheme's hygienic 
macros with the Camlp4 preprocessor, or even if it does make sense with 
it.
More generally, i'm looking for some good point-to-point comparison 
between OCaml and Scheme on the macro side...if u know some good 
ressource on that, please point it to me !

Thanks,

Pierre CHATEL

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 34+ messages in thread
* [Caml-list] Camlp4
@ 2003-02-07 11:11 Daniel de Rauglaudre
  2003-02-08  0:26 ` Issac Trotts
  2003-02-08 17:23 ` Geoff Wozniak
  0 siblings, 2 replies; 34+ messages in thread
From: Daniel de Rauglaudre @ 2003-02-07 11:11 UTC (permalink / raw)
  To: caml-list

Hi everybody,

I am in regret to announce that I have stopped developping Camlp4 and
other OCaml applications. I am sure that the Cristal team is going to
find some good programmers able to maintain the Camlp4 part of OCaml
and I wish good luck to the language.

-- 
Daniel de RAUGLAUDRE
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 34+ messages in thread
* [Caml-list] Camlp4
@ 2002-05-17 13:19 Ohad Rodeh
  0 siblings, 0 replies; 34+ messages in thread
From: Ohad Rodeh @ 2002-05-17 13:19 UTC (permalink / raw)
  To: caml-list


List,
   I'm writing to check whether Camlp4 remains or not in the Caml
distribution.

I have a 60000 line system written in Caml, and I was seriously considering
using
Camlp4 for conditional compilation of debugging versions of some of my
modules.

      Ohad.

PS
    While I don't develop Caml, I personally think that:
o Caml needs a preprocessor, at least for conditional compilation
o The preprocessor needs to be in the primary distribution (not as an
add-on)
o Since there is a lot of code written in the old syntax, changing the
syntax is out
   of the question.
o The above point means that a preprocessor is needed to experiment with
new
    syntax without breaking the old syntax.

-----------------------------------------------------------------------------------

Ohad Rodeh
tel: +972-9-9527641
IBM Haifa, storage research


                                                                                                                         
                      Christopher Quinn                                                                                  
                      <cq@htec.demon.co.uk>         To:                                                                  
                      Sent by:                      cc:       caml-list@inria.fr                                         
                      owner-caml-list@pauill        Subject:  [Caml-list] Re: Camlp4/OCaml                               
                      ac.inria.fr                                                                                        
                                                                                                                         
                                                                                                                         
                      17/05/2002 02:22                                                                                   
                      Please respond to                                                                                  
                      Christopher Quinn                                                                                  
                                                                                                                         
                                                                                                                         



How can camlp4 be unimportant or a waste of time!

Here are some things I find useful about it:

o conditional compilation

o ability to add command line options to switch between one's own 'safe'
modules and their 'unsafe' versions which can only be done in the case
of Arrays and Strings with the standard compiler.

o one can always modify one's own copy of the parser,
but that's a bother when something in the original changes, and besides,
camlp4's extension mechanism allows a compact and manageable format.

o no matter how one redefines the syntax, just running the source
through camlp4 can reconstruct it in the vanilla form. So no one ever
needs to suffer another's idea of perfection!

o camlp4 seems to me to be one way to avoid the endless creation of
mini-languages for specific tasks that end up trying to do stuff beyond
their limited design. Better to start with the expressivity of the likes
of caml, maybe cutting down, and augment with p4 extensions. I'm
planning to embed some sql style DDL for my project.

o I can write code without_the_god_damn_awful_underscore character
stressing my hands and use-an-alternative-even
(though-I-am-no-fan-of-lisp)!


I felt these reasons were compelling enough to justify  switching to
camlp4 as my default parser.

The above doubtless has no bearing on the technical arguments for not
having camlp4 in the distribution.
I just want to say I think camlp4 is important and indispensible.

- chris

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives:
http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ:
http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners




-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners


^ permalink raw reply	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2010-02-09 18:29 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-03 12:57 [Caml-list] novice puzzled by speed tests dolfi
2004-01-04 16:49 ` Xavier Leroy
2004-01-04 20:49   ` Brian Hurt
2004-01-05 19:50   ` [Caml-list] camlp4 Ker Lutyn
  -- strict thread matches above, loose matches on Subject: below --
2010-02-06  1:16 camlp4 Andy Ray
2010-02-06 11:15 ` [Caml-list] camlp4 blue storm
2010-02-06 12:14 ` Tiphaine Turpin
2010-02-06 12:44   ` Guillaume Yziquel
2010-02-09 15:30     ` Guillaume Yziquel
2010-02-09 18:29       ` Jake Donham
2010-02-07 17:19   ` Martin DeMello
2010-02-08  1:14     ` Ashish Agarwal
2010-02-08  2:01       ` Yoann Padioleau
2010-02-08  2:03       ` Erik de Castro Lopo
2010-02-06 13:37 ` Ed Keith
2010-02-07 13:51 ` Joseph Young
2008-01-18 17:08 camlp4 Christian Sternagel
2008-01-18 18:56 ` [Caml-list] camlp4 Nicolas Pouillard
2008-01-18 19:30 ` Olivier Andrieu
2008-01-18 19:53   ` Nicolas Pouillard
2008-01-19 15:09     ` Christian Sternagel
2008-01-20 15:23       ` Nicolas Pouillard
2008-01-22 13:33         ` Christian Sternagel
2008-01-22 13:42           ` Nicolas Pouillard
2008-01-22 14:06             ` Loup Vaillant
2008-01-22 14:26               ` Nicolas Pouillard
2008-01-22 16:43             ` Christian Sternagel
2008-01-22 18:20               ` Nicolas Pouillard
2008-01-24  9:01                 ` Christian Sternagel
2003-07-08 12:49 [Caml-list] -unsafe and camlp4 "Dmitry Bely" 
2003-07-08 13:38 ` Xavier Leroy
2003-07-08 15:38   ` [Caml-list] camlp4 Dmitry Bely
2003-07-22 11:14     ` Damien Doligez
2003-06-10 14:22 Pierre CHATEL
2003-02-07 11:11 [Caml-list] Camlp4 Daniel de Rauglaudre
2003-02-08  0:26 ` Issac Trotts
2003-02-08 17:23 ` Geoff Wozniak
2002-05-17 13:19 Ohad Rodeh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).