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)
_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to