chicken-users
[Top][All Lists]
Advanced

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

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


From: Shawn Wagner
Subject: Re: [Chicken-users] how to speed up my text filter?
Date: Tue, 24 Sep 2013 18:18:38 -0700

Increasing the initial heap size to something big enough it doesn't need
to do much or any GC (Something like csc -:hi500M -:hs0 foo.scm) might
help.

On Tue, 24 Sep 2013 18:35:10 -0400

Xin Zheng <address@hidden> wrote:

> 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)


-- 
Shawn Wagner
address@hidden




reply via email to

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