[erlang-questions] Idiom for multiple case matches

David Mercer <>
Mon Nov 10 20:16:37 CET 2008


Actually, using Ulf's ct_expand parse transform, the results on the set look
much better:

1000000 Iterations
        Virding: Run-Time/Wall-Clock: 94/94 milliseconds
        Cronqvist: Run-Time/Wall-Clock: 141/140 milliseconds
        Mercer: Run-Time/Wall-Clock: 843/844 milliseconds

That's a 17x speed-up!

However, now I get a compile warning:

	./test.erl:0: Warning: variable 'V42' is unused

I don't know enough about parse transforms to debug.  Is there any
documentation on creating them?

DBM

> -----Original Message-----
> From: Ulf Wiger (TN/EAB) [mailto:]
> Sent: Monday, November 10, 2008 12:30
> To: 
> Cc: 'Erlang Questions'
> Subject: Re: [erlang-questions] Idiom for multiple case matches
> 
> 
> So try it with the absolutely wonderful and indispensable
> parse transform utility ct_expand.  ;-)
> 
> http://forum.trapexit.org/viewtopic.php?p=20260#20260
> 
> 
> BR,
> Ulf W
> 
> 
> David Mercer skrev:
> > For completeness, I did run some benchmarking.  I hesitate to put my
> name to
> > my solution, since it was suggested in jest, but I am vindicated because
> it
> > performed as expected:
> >
> > 1,000,000 Iterations:
> >         Virding: Run-Time/Wall-Clock: 94/94 milliseconds
> >         Cronqvist: Run-Time/Wall-Clock: 141/141 milliseconds
> >         Mercer: Run-Time/Wall-Clock: 14547/14547 milliseconds
> >
> > Cheers,
> >
> > David
> >
> >> -----Original Message-----
> >> From: David Mercer [mailto:]
> >> Sent: Monday, November 10, 2008 11:05
> >> To: 'mats cronqvist'; 'Michael Radford'
> >> Cc: 'Hynek Vychodil'; 'Erlang Questions'
> >> Subject: RE: [erlang-questions] Idiom for multiple case matches
> >>
> >> Since this is, semantically, a set operation, should we not perhaps use
> >> sets:is_element/2 instead?  Something like:
> >>
> >> 	vowels() -> sets:from_list("aeiou").
> >> 	is_vowel(C) -> sets:is_element(C, vowels()).
> >>
> >> Just kidding, of course... (Obvious efficiency issues.) :-)
> >>
> >> DBM
> >>
> >> P.S. No, Mats, I did not benchmark this. :-)
> >
> > _______________________________________________
> > erlang-questions mailing list
> > 
> > http://www.erlang.org/mailman/listinfo/erlang-questions




More information about the erlang-questions mailing list