From c78f367d9f3e3f157f575a0d37aafac93f86d42a Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Sun, 20 Jun 2010 18:24:44 -0400 Subject: [PATCH] Another simple improvement, making things about twice faster. Total speedup is now ~14x. --- .../tests/racket/benchmarks/shootout/fasta.rkt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/collects/tests/racket/benchmarks/shootout/fasta.rkt b/collects/tests/racket/benchmarks/shootout/fasta.rkt index 9c2c763d7d..7943593fac 100644 --- a/collects/tests/racket/benchmarks/shootout/fasta.rkt +++ b/collects/tests/racket/benchmarks/shootout/fasta.rkt @@ -7,8 +7,11 @@ ;; ;; Very loosely based on the Chicken variant by Anthony Borla, some ;; optimizations taken from the GCC version by Petr Prokhorenkov, and -;; additional optimizations by Eli Barzilay (not really related to the -;; above two now). +;; additional heavy optimizations by Eli Barzilay (not really related to +;; the above two now). +;; +;; If you use some of these optimizations in other solutions, please +;; include a proper attribution to this Racket code. (define +alu+ (bytes-append #"GGCCGGGCGCGGTGGCTCACGCCTGTAATCCCAGCACTTTGG" @@ -59,7 +62,14 @@ (define IM 139968) (define IM.0 (fx->fl IM)) -(define (random-next cur) (fxmodulo (fx+ IC (fx* cur IA)) IM)) +(define-syntax-rule (define/IM (name id) E) + (begin (define V + (let ([v (make-vector IM)]) + (for ([id (in-range IM)]) (vector-set! v id E)) + v)) + (define-syntax-rule (name id) (vector-ref V id)))) + +(define/IM (random-next cur) (fxmodulo (fx+ IC (fx* cur IA)) IM)) (define (make-lookup-table frequency-table) (define v (make-bytes IM))