Do the times change if you put an 'in-range' in the for loops?<span></span><br><br>On Sunday, June 9, 2013, Asumu Takikawa wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On 2013-05-31 19:40:52 -0400, Asumu Takikawa wrote:<br>
> Is it feasible to get `member` to have the same optional argument<br>
> behavior as `assoc`? That is, to have an equality predicate as the third<br>
> argument.<br>
<br>
I went ahead and implemented this behavior and submitted a pull request:<br>
<a href="https://github.com/plt/racket/pull/366" target="_blank">https://github.com/plt/racket/pull/366</a><br>
<br>
To see if the change is "pay as you go", I ran some microbenchmarks to<br>
see if old-style `member` calls would slow down (see below). There<br>
doesn't seem to be any significant slow-down AFAICT.<br>
<br>
I was surprised that the non-JIT version was faster in the first case<br>
but much slower in the second microbenchmark though. (note: I had to<br>
change the C implementation of `member` for the non-JIT path)<br>
<br>
I'd appreciate any suggestions on the code.<br>
<br>
Cheers,<br>
Asumu<br>
<br>
;;; NEW BRANCH<br>
$ racket member-benchmark.rkt<br>
cpu time: 1748 real time: 1752 gc time: 0<br>
$ racket --no-jit member-benchmark.rkt<br>
cpu time: 1524 real time: 1526 gc time: 0<br>
<br>
;;; MASTER<br>
$ racket member-benchmark.rkt<br>
cpu time: 1712 real time: 1716 gc time: 0<br>
$ racket --no-jit member-benchmark.rkt<br>
cpu time: 1524 real time: 1528 gc time: 0<br>
<br>
The microbenchmark is just this:<br>
#lang racket/base<br>
(require (only-in racket/list range))<br>
(define lst (range 1 5000))<br>
(time<br>
(for ([i 30000])<br>
(member 2500 lst)))<br>
<br>
On a slightly different microbenchmark:<br>
<br>
;;; NEW BRANCH<br>
$ racket member-benchmark-2.rkt<br>
cpu time: 2396 real time: 2402 gc time: 0<br>
$ racket --no-jit member-benchmark-2.rkt<br>
cpu time: 7156 real time: 7174 gc time: 0<br>
<br>
;;; MASTER<br>
$ racket member-benchmark-2.rkt<br>
cpu time: 2412 real time: 2416 gc time: 0<br>
$ racket --no-jit member-benchmark-2.rkt<br>
cpu time: 6892 real time: 6911 gc time: 0<br>
<br>
#lang racket/base<br>
(define lst '(a b c))<br>
(time<br>
(for ([i 30000000])<br>
(member 'b lst)))<br>
<br>
_________________________<br>
Racket Developers list:<br>
<a href="http://lists.racket-lang.org/dev" target="_blank">http://lists.racket-lang.org/dev</a><br>
</blockquote>