[racket-dev] racket/gui performance problem when using lots of items in table-panels

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Thu Jul 19 11:08:11 EDT 2012

I think the problem is the time it takes to create 600 buttons in this
case, not the time needed to switch between the tabs. I'm not sure
why you are recreating them each refresh. Am I missing something?

Doug

On Thu, Jul 19, 2012 at 8:59 AM, Marijn <hkBst at gentoo.org> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hi,
>
> I've been having some performance problems when using lots of items in
> table-panels[1]. Switching tabs when running the following example
> exhibits the problem. Can anything be done about it?
>
> Marijn
>
>
> #lang racket/gui
>
> ;(require (planet williams/table-panel:1:1/table-panel))
> (require "table-panel.rkt")
>
> ;;; The top-level frame
> (define frame
>   (new frame%
>        (label "Table Panel Perf Test")
>        (width 500) (height 500)))
>
> (define (current-root-tab)
>   (vector-ref root-tab-vector (send root-tab-panel get-selection)) )
>
> (define (delete-all-children area)
>   (send area change-children
>         (lambda (children) '())) )
>
> (define (root-tab-callback tab-panel event)
>   (send root-tab-panel change-children
>         (lambda (children) (list (current-root-tab)))) )
>
> (define root-tab-panel
>   (new tab-panel%
>        (choices '()#;tab-names)
>        (parent frame)
>        (callback root-tab-callback)))
>
> (define nr-rows 30)
> (define nr-cols 20)
>
> (define on-show-refresh-panel%
>   (class table-panel%
>     (init-field refresher)
>     (super-new)
>     (define/override (on-superwindow-show shown?)
>       (when shown?
>         (displayln "refreshing!")
>         (refresher)))
>     ))
>
> (define tab1
>   (new panel% (parent root-tab-panel)))
>
> (define (build-tab2)
>   (delete-all-children tab2)
>   (for* ((r nr-rows)
>          (c nr-cols))
>         (new button%
>              (parent tab2)
>              (label (format "~a,~a" r c))
>              (stretchable-width #t)
>              (stretchable-height #t)
>              (callback
>               (lambda (button event)
>                 (printf "~a~n"
>                         (send button get-label)))) )  ))
>
> (define tab2
>   (new on-show-refresh-panel% (parent root-tab-panel)
>        (style '(deleted))
>        (alignment '(center center))
>        (dimensions `(,nr-cols ,nr-rows))
>        (refresher build-tab2)))
>
> (define tabs
>   `((,tab1 . "Tab 1")
>     (,tab2 . "Tab 2")))
>
> (define tab-names (map cdr tabs))
> (define root-tab-vector (list->vector (map car tabs)))
>
> (send root-tab-panel set tab-names)
>
> (send frame show #t)
>
>
> [1]:http://planet.racket-lang.org/display.ss?package=table-panel.plt&owner=williams
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v2.0.19 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAlAIIMoACgkQp/VmCx0OL2x3CgCbBhGkCCroHrEj1giTYA7KYhC4
> 3sgAoMLUC6S+zouYY4kXm4HFca85odPG
> =n8MG
> -----END PGP SIGNATURE-----
> _________________________
>   Racket Developers list:
>   http://lists.racket-lang.org/dev

Posted on the dev mailing list.