/usr/share/scheme48-1.9/env/profile-check.scm is in scheme48 1.9-5.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 | ; Part of Scheme 48 1.9. See file COPYING for notices and license.
; Authors: Marcel Turino, Manuel Dietrich
; Profiler tests
(define-test-suite profiler-tests)
(define (a-loop y)
(+ 1
(let loop ((i y))
(if (> i 0)
(loop (- i 1))
0))))
(define (main-simple-loop x)
(+ 1
(a-loop x)
(a-loop x)))
(define (a-rec y)
(+ 1
(if (> y 0)
(a-rec (- y 1))
0)))
(define (main-rec x)
(+ 1
(a-rec x)
(a-rec x)))
(define (c-mutual x)
(+ 1 x))
(define (b-mutual x)
(let ((y (- x 1)))
(if (> y 0)
(begin
(a-mutual y)
(c-mutual (* 2 y))
(+ 1 (a-mutual y)))
0)))
(define (a-mutual x)
(let ((y (- x 1)))
(if (> y 0)
(begin
(b-mutual y)
(c-mutual y)
(+ 1 (b-mutual y)))
0)))
(define (main-mutual x)
(+ 1
(a-mutual x)
(a-mutual x)))
(define (a-exitcont cont x)
(let ((y (- x 1)))
(if (> y 0)
(begin
(check-exception
(profile-thunk (make-empty-profile-data) (lambda () (main-exitcont 10))))
(cont 0))
0)))
(define (main-exitcont cont x)
(+ 1 (a-exitcont cont x)))
(define-test-case simple-loop profiler-tests
(let ((prof-data (make-empty-profile-data))
(blackhole (make-string-output-port)))
;; let it run
(profile-thunk prof-data (lambda () (main-simple-loop 5000)) 1)
(test-stability prof-data "a-loop")
(check (profile-function-calls prof-data '("a-loop"))
=> 2)
(check (profile-function-calls prof-data '("loop" "a-loop"))
=> 10002)
(check (profile-function-reccalls prof-data '("loop"))
=> 0) ; tail calls, this could fail when profiler enhances :(
(check (profile-function-nonreccalls prof-data '("a-loop"))
=> 2)
))
(define-test-case recursive profiler-tests
(let ((prof-data (make-empty-profile-data))
(blackhole (make-string-output-port)))
;; let it run
(profile-thunk prof-data (lambda () (main-rec 500)) 50)
(test-stability prof-data "a-rec")
(check (profile-function-calls prof-data '("a-rec"))
=> 1002)
(check (profile-function-calls prof-data '("main-rec"))
=> 1)
(check (profile-function-reccalls prof-data '("a-rec" "profiler-test"))
=> 1000)
(check (profile-function-nonreccalls prof-data '("a-rec"))
=> 2)
))
(define-test-case mutual profiler-tests
(let ((prof-data (make-empty-profile-data))
(blackhole (make-string-output-port)))
;; let it run
(profile-thunk prof-data (lambda () (main-mutual 15)) 50 #f)
(test-stability prof-data "a-mutual")
(check (profile-function-calls prof-data '("a-mutual"))
=> 43690)
(check (profile-function-calls prof-data '("main-mutual"))
=> 1)
(check (profile-function-reccalls prof-data '("a-mutual" "profiler-test"))
=> 0)
(check (profile-function-nonreccalls prof-data '("a-mutual"))
=> 43690)
))
(define-test-case exitcont profiler-tests
(let ((prof-data (make-empty-profile-data))
(blackhole (make-string-output-port)))
;; let it run
(call-with-current-continuation
(lambda (cont)
(profile-thunk prof-data (lambda () (main-exitcont cont 22)) 50 #t)))
(test-stability prof-data "a-exitcont")
(check (profile-function-calls prof-data '("a-exitcont"))
=> 1)
(check (profile-function-calls prof-data '("main-exitcont"))
=> 1)
(check (profile-function-reccalls prof-data '("a-exitcont" "profiler-test"))
=> 0)
(check (profile-function-nonreccalls prof-data '("a-exitcont"))
=> 1)
))
;; non-deterministic, but should at least not crash...
(define (test-stability prof-data funcname)
(let ((blackhole (make-string-output-port)))
(profile-display prof-data blackhole)
(profile-display-overview prof-data blackhole)
(profile-display-flat prof-data blackhole)
(profile-display-tree prof-data blackhole)
(profile-data-starttime prof-data)
(profile-data-endtime prof-data)
(profile-data-memoryuse prof-data)
(profile-data-gcruns prof-data)
(profile-data-runtime prof-data)
(profile-data-samples prof-data)
(profile-data-templates prof-data)
(profile-data-cycles prof-data)
(profile-data-root prof-data)
(profile-display-function-flat prof-data '(funcname) blackhole)
(profile-display-function-tree prof-data '(funcname "profiler-test" blackhole))
(profile-display-function-tree prof-data "profiler-test" blackhole)
(profile-display-function-cycle prof-data '(funcname) blackhole)
))
|