[plt-dev] DrScheme's zippyness: linux & fonts

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Tue Aug 25 00:11:34 EDT 2009

I've noticed that (on my netbook, running linux) the choice of font
can be a significant factor in how zippy DrScheme feels. I'm sure that
eventually there will be improvements to the infrastructure to speed
things up, but in the meantime you can at least get a feel for the
text drawing speed with the code below.

Just to give you some sense of this, on my machine the times range
from 3 msec to 275 msec, a huge range! Also note that you may want to
run the code multiple times; it sometimes gives bad results (I'm not
sure why).

Robby

PS: you probably want to be sure that λ shows up in your font of
choice. Some of the faster ones won't be able to render it (proably).

#lang scheme/gui

(define bdc (make-object bitmap-dc% (make-object bitmap% 1 1)))

;; time-drawing face -> number
;; times how long drawing with 'face' face takes
(define (time-drawing face)
  (let loop ()
    (let-values ([(res cpu real gc) (time-apply (do-drawing face) '())])
      real)))

;; do-drawing : face -> -> void
;; draws some text into 'bdc' using the given face
(define ((do-drawing face))
  (let ([font (send the-font-list find-or-create-font
                    12 face 'default
                    'normal 'normal)])
    (send bdc set-font font)
    (let loop ([n 100])
      (unless (zero? n)
        (send bdc draw-text
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" 0 0)
        (loop (- n 1))))))

;; draw with all of the monospace fonts and sort the results
(sort
 (map (λ (x) (list x (time-drawing x)))
      (get-face-list 'mono))
 < #:key cadr)


Posted on the dev mailing list.