chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-users] how to speed up my text filter?


From: Xin Zheng
Subject: [Chicken-users] how to speed up my text filter?
Date: Tue, 24 Sep 2013 18:35:10 -0400

Hi all,

I am a newbie to Chicken Scheme. Use compiled following filter, I am trying to filter a text file with 1 million lines. It took 10 seconds, while profiling showed that 90% time used on GC. I am wondering if any way to speed it up.

Any help would be appreciated.

Thanks,
Zin


(use chicken extras)
(define args ( argv))
(define f (list-ref args 1))
(define in (open-input-file f))
(define out (open-output-file (list-ref args 2)) )

(define (process line)
  (if (eq? #\@ (string-ref line 0))
      '()
      (let* ([eles (string-split line "\t")]
             [ref (list-ref eles 2)]
             [id (list-ref eles 0)])
        (if (eq? (string-ref ref 0) #\*)
            (write-line id out)))))

(let loop ([l (read-line in)])
  (if (eof-object? l)
      (write-line "done" (current-error-port))
      (begin (process l)
             (loop (read-line in)))))

(close-input-port in)
(close-output-port out)


reply via email to

[Prev in Thread] Current Thread [Next in Thread]