summaryrefslogtreecommitdiff
path: root/gc-benchmarks/larceny/dumb.sch
blob: 353564a8aa7aa6770e343fccdc1a4709ef1119e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
; Dumb benchmark to test the reporting of words marked during gc.
; Example: (foo 1000000)

(define (ballast bytes)
  (do ((bytes bytes (- bytes 8))
       (x '() (cons bytes x)))
      ((zero? bytes) x)))

(define (words-benchmark bytes0 bytes1)
  (let ((x (ballast bytes0)))
    (do ((bytes1 bytes1 (- bytes1 8)))
        ((not (positive? bytes1))
         (car (last-pair x)))
        (cons (car x) bytes1))))

(define (foo n)
  (collect)
  (display-memstats (memstats))
  (run-benchmark "foo" (lambda () (words-benchmark 1000000 n)) 1)
  (display-memstats (memstats)))