[racket-dev] [plt] Push #20559: master branch updated

From: Sam Tobin-Hochstadt (samth at ccs.neu.edu)
Date: Wed Jun 23 18:12:36 EDT 2010

On Wed, Jun 23, 2010 at 4:14 PM,  <eli at racket-lang.org> wrote:
> 3f36d05 Eli Barzilay <eli at barzilay.org> 2010-06-23 16:10
> :
> | Turn contracts on `enqueue!' and `dequeue!' into the usual error checks.
> |
> | On a simple benchmark of:
> |
> |   (let ([N 100000]
> |         [M 20]
> |         [q (make-queue)])
> |     (time (for ([i (in-range M)])
> |             (for ([i (in-range (* i N))]) (enqueue! q i))
> |             (unless (for/and ([i (in-range (* i N))]) (list i (dequeue! q)))
> |               (error "poof")))))
> |
> | I get these timings:
> |
> |   original version: cpu time: 24438 real time: 24439 gc time: 8164
> |   single-links:     cpu time: 17848 real time: 17849 gc time: 4859
> |   this version:     cpu time:  6519 real time:  6519 gc time: 3032
> |

Do we really want to remove contracts from code just because they
don't perform as well as hand-written checks?  Contracts offer a lot
of advantages that hand-written checks don't have.  Also, did you try
just changing the result contract from `void?' to `any/c'?

-- 
sam th
samth at ccs.neu.edu


Posted on the dev mailing list.