This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: help to get this running faster
- To: djurfeldt at nada dot kth dot se
- Subject: Re: help to get this running faster
- From: David Pirotte <david at altosw dot be>
- Date: Tue, 05 Sep 2000 12:27:43 +0200
- CC: guile-user at gnu dot org
- List-Id: <guile-user.gnu.org>
- Organization: Alto Sotware (http://www.altosw.be)
- References: <39B2C183.430FC816@altosw.be> <xy7snrhkvse.fsf@mdj.nada.kth.se>
Mikael Djurfeldt wrote:
> ...
> 1. The support for optional arguments is currently slow. Don't use
> this in inner loops.
>
> 2. Guile's implementation of continuations is heavy. Again, avoid
> this in inner loops.
>
> 3. `read-line' is currently an interpreted Scheme closure. We should
> optimize this, but haven't got to it yet. If you can use the
> low-level %read-line as a temporary kludge, this will speed up your
> code.
Many thanaks to all suggestions, here is what I did:
can someone give me a little example on how I could get precise figures on
execution time, cons ...
thanks,
david
;; -- module (alto tabreader)
(define-module (alto tabreader))
(export char-pos
get-tokens
load-records)
;; (use-modules (ice-9 optargs))
;; (use-modules (ice-9 format))
(define (char-pos char str start end)
;; (format #t "Char: ~A~%Str: ~A~%Start: ~A~%End: ~A~%"
;; char str start end)
(catch 'exit
(lambda ()
(do ((i start (+ i 1)))
((>= i end) #f)
(if (char=? (string-ref str i) char)
(throw 'exit i))))
(lambda (key index)
index)))
;; (char-pos #\tab "david pirotte")
(define (get-tokens str sep)
(let ((tokens '())
(start 0)
(str-len (string-length str)))
(do ((end (char-pos sep str start str-len)))
((not end)
(reverse! (cons (substring str start str-len) tokens)))
(set! tokens (cons (substring str start end) tokens))
(set! start (+ 1 end))
(set! end (char-pos sep str start str-len)))))
;; (get-tokens "david pirotte musician")
(define (load-records fname field-sep)
(call-with-input-file fname
(lambda (i-stream)
(do ((records '())
(line (%read-line i-stream) (%read-line i-stream)))
((eof-object? (car line)) (reverse! records))
(set! records (cons (get-tokens (car line) field-sep)
records))))))
;; (load-records "/usr/alto/projects/postgres/essai-122.tab" #\tab)
;; (load-records "/usr/alto/projects/psion/revo/backup/palm-adresses.txt" #\tab)
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://mail.gnu.org/mailman/listinfo/guile-user