Last active
August 29, 2015 14:00
-
-
Save Metaxal/11142941 to your computer and use it in GitHub Desktop.
Simple test showing big-bang being slow at rendering on screen in new version
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#lang racket | |
;;; Run this file with `racket test-big-bang.rkt` | |
;;; then type quickly "asdf" to trigger several successive to-draw events. | |
;;; Drawing the scene is fast, but rendering it on-screen is very slow? | |
(require 2htdp/image | |
2htdp/planetcute | |
2htdp/universe) | |
(define elt-width (image-width grass-block)) | |
(define elt-height (image-height grass-block)) | |
(define elt-height/2 (/ elt-height 2)) | |
(define view-width 800) | |
(define view-height 400) | |
(define window-width view-width) | |
(define window-height (+ view-height elt-height)) | |
(define grid-size 10) | |
(define (stack-rows . col-picts) | |
(for/fold ([img empty-image]) | |
([cp col-picts]) | |
(underlay/align/offset | |
"center" "bottom" | |
img 0 elt-height/2 cp))) | |
(define (client-draw-all) | |
(apply stack-rows | |
(for/list ([i grid-size]) | |
(apply beside/align "bottom" | |
(for/list ([j grid-size]) | |
grass-block))))) | |
(define t0 (current-milliseconds)) | |
(define (print-time str) | |
(printf "~a at ~a\n" str (- (current-milliseconds) t0))) | |
(big-bang | |
'() | |
(to-draw (λ(w) | |
(print-time "to-draw") | |
(display "to-draw: ") | |
(time | |
#;(empty-scene window-width window-height) | |
(client-draw-all))) | |
window-width window-height) | |
(on-key (λ(w k)(print-time (format "on-key ~a" k))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Timings:
to-draw at 2
to-draw: cpu time: 0 real time: 2 gc time: 0
on-key a at 6906
on-key u at 6912
on-key i at 6912
on-key e at 6913
to-draw at 6913
to-draw: cpu time: 4 real time: 3 gc time: 0
to-draw at 8598
to-draw: cpu time: 4 real time: 2 gc time: 0
to-draw at 11948
to-draw: cpu time: 4 real time: 2 gc time: 0
to-draw at 13631
to-draw: cpu time: 0 real time: 2 gc time: 0
to-draw at 161839
to-draw: cpu time: 4 real time: 9 gc time: 0