guile-user
[Top][All Lists]
Advanced

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

GOOPS Slowness (make <generic>)


From: Andreas Rottmann
Subject: GOOPS Slowness (make <generic>)
Date: Sun, 26 Oct 2003 17:57:28 +0100
User-agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.3 (gnu/linux)

Hi!

Investigating why the guile-gobject GTK+2 bindings take so long to
load, I found out the following interesting fact, which is a reason
for part of the slowness, as the benchmark shows.

;; -*- Mode: scheme; -*-

(use-modules (oop goops))

(with-benchmark-prefix "make <generic>"
        
  (benchmark "plain" 10000
     (make <generic>))

  (benchmark "with name" 10000
    (make <generic> #:name 'a-gf)))

             
On my Athlon 900, I get this results (using Guile from current CVS):

address@hidden:~/src/foreign/guile/guile-core/benchmark-suite% 
GUILE_LOAD_PATH=.. ./guile-benchmark --benchmark-suite=`pwd` benchmarks/goops.bm
;; calibrating the benchmarking framework...
;; framework time per iteration: 2.11715698242188e-6
("benchmarks/goops.bm: make <generic>: plain" 10000 user 0.47 benchmark 
0.448828430175781 bench/interp 0.338828430175781 gc 0.11)
("benchmarks/goops.bm: make <generic>: with name" 10000 user 10.68 benchmark 
10.6588284301758 bench/interp 10.3588284301758 gc 0.3)

This means that generic function creation with specifing the #:name
keyword is slower by a factor of 20 (!), when I read the above
right. After peeking into oop/goops.scm a bit I discovered the
following:


(define-method (initialize (generic <generic>) initargs)
  (let ((previous-definition (get-keyword #:default initargs #f))
        (name (get-keyword #:name initargs #f)))
    (next-method)
    (slot-set! generic 'methods (if (is-a? previous-definition <procedure>)
                                    (list (make <method>
                                                #:specializers <top>
                                                #:procedure
                                                (lambda l
                                                  (apply previous-definition
                                                         l))))
                                    '()))
    (if name
        (set-procedure-property! generic 'name name))
    ))

It seems that either set-procedure-property! or get-keyword is
probably the culprit, however, I'm not a Guile hacker...

Regards, Andy
-- 
Andreas Rottmann         | address@hidden      | address@hidden | address@hidden
http://www.8ung.at/rotty | GnuPG Key: http://www.8ung.at/rotty/gpg.asc
Fingerprint              | DFB4 4EB4 78A4 5EEE 6219  F228 F92F CFC5 01FD 5B62

Say NO to Software Patents! -- http://petition.eurolinux.org/




reply via email to

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