diff options
author | Ludovic Court`es <ludovic.courtes@laas.fr> | 2005-05-02 16:32:32 +0000 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2008-04-25 19:09:30 +0200 |
commit | f41cb00ce25d0263bb58e83e3d632ec6bf79b05a (patch) | |
tree | 1c5fc0ae707fa3bf8b2fc55ff220332bc6a8f285 /benchmark/lib.scm | |
parent | 2d80426a3ec7de15a194d0baed0e9f4be8659b92 (diff) |
Fixed a stack leak. Now observing actual performance.
* src/*.[ch]: Replaced `scm_mem2symbol' by `scm_from_locale_symboln' and
`scm_ulong2num' by `scm_from_ulong'.
* src/vm_system.c (tail-call): Fixed stack leak (SP lacked decrement by
one more Scheme object in the tail-recursive case).
* benchmark/measure.scm (measure): Make sure we are using the compiled
procedure (i.e. a program object) when measuring. This yields better
results than before. :-)
* doc/guile-vm.texi: Augmented the instruction set documentation with
branch instructions, `call' and `tail-call'.
git-archimport-id: lcourtes@laas.fr--2004-libre/guile-vm--revival--0.6--patch-7
Diffstat (limited to 'benchmark/lib.scm')
-rw-r--r-- | benchmark/lib.scm | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/benchmark/lib.scm b/benchmark/lib.scm index f272842b3..31e524453 100644 --- a/benchmark/lib.scm +++ b/benchmark/lib.scm @@ -16,12 +16,12 @@ (g-c-d x (- y x)) (g-c-d (- x y) y)))) -(define (loop how-long) +(define (loop n) ;; This one shows that procedure calls are no faster than within the ;; interpreter: the VM yields no performance improvement. - (if (= 0 how-long) + (if (= 0 n) 0 - (loop (1- how-long)))) + (loop (1- n)))) ;; Disassembly of `loop' ;; @@ -35,7 +35,7 @@ ; 11 (link "1-") ; 15 (vector 3) ; 17 (make-int8:0) ;; 0 -; 18 (load-symbol "how-long") ;; how-long +; 18 (load-symbol "n") ;; n ; 28 (make-false) ;; #f ; 29 (make-int8:0) ;; 0 ; 30 (list 3) @@ -92,25 +92,27 @@ ; 23 (tail-call 1) -(define (loopi how-long) +(define (loopi n) ;; Same as `loop'. - (let loopi ((how-long how-long)) - (if (= 0 how-long) + (let loopi ((n n)) + (if (= 0 n) 0 - (loopi (1- how-long))))) + (loopi (1- n))))) (define (do-cons x) ;; This one shows that the built-in `cons' instruction yields a significant - ;; improvement (speedup: 1.4). + ;; improvement (speedup: 1.5). (let loop ((x x) (result '())) (if (<= x 0) result (loop (1- x) (cons x result))))) +(define big-list (iota 500000)) + (define (copy-list lst) - ;; Speedup: 1.3. + ;; Speedup: 5.9. (let loop ((lst lst) (result '())) (if (null? lst) |