Skip to content

Commit 7ae600f

Browse files
authored
Merge pull request #137 from herbie-fp/no-heap-timing
Don't put timestamps on the heap for recording
2 parents af69837 + 673c67a commit 7ae600f

File tree

2 files changed

+20
-30
lines changed

2 files changed

+20
-30
lines changed

eval/run.rkt

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
(require racket/match
44
racket/function
5-
racket/flonum)
5+
racket/flonum
6+
racket/performance-hint)
67

78
(require "machine.rkt"
89
"adjust.rkt"
@@ -20,22 +21,23 @@
2021
(set-rival-machine-bumps! machine 0)
2122
(*bumps-activated* #f))
2223

23-
(define (rival-machine-record machine name number precision time memory iter)
24-
(define profile-ptr (rival-machine-profile-ptr machine))
25-
(define profile-instruction (rival-machine-profile-instruction machine))
26-
(when (< profile-ptr (vector-length profile-instruction))
27-
(define profile-number (rival-machine-profile-number machine))
28-
(define profile-time (rival-machine-profile-time machine))
29-
(define profile-memory (rival-machine-profile-memory machine))
30-
(define profile-precision (rival-machine-profile-precision machine))
31-
(define profile-iteration (rival-machine-profile-iteration machine))
32-
(vector-set! profile-instruction profile-ptr name)
33-
(vector-set! profile-number profile-ptr number)
34-
(vector-set! profile-memory profile-ptr memory)
35-
(vector-set! profile-precision profile-ptr precision)
36-
(vector-set! profile-iteration profile-ptr iter)
37-
(flvector-set! profile-time profile-ptr time)
38-
(set-rival-machine-profile-ptr! machine (add1 profile-ptr))))
24+
;; Inlining critical, otherwise `time` is heap-allocated (Chez boxes floats)
25+
(define-inline (rival-machine-record machine name number precision time memory iter)
26+
(define profile-ptr (rival-machine-profile-ptr machine))
27+
(define profile-instruction (rival-machine-profile-instruction machine))
28+
(when (< profile-ptr (vector-length profile-instruction))
29+
(define profile-number (rival-machine-profile-number machine))
30+
(define profile-time (rival-machine-profile-time machine))
31+
(define profile-memory (rival-machine-profile-memory machine))
32+
(define profile-precision (rival-machine-profile-precision machine))
33+
(define profile-iteration (rival-machine-profile-iteration machine))
34+
(vector-set! profile-instruction profile-ptr name)
35+
(vector-set! profile-number profile-ptr number)
36+
(vector-set! profile-memory profile-ptr memory)
37+
(vector-set! profile-precision profile-ptr precision)
38+
(vector-set! profile-iteration profile-ptr iter)
39+
(flvector-set! profile-time profile-ptr time)
40+
(set-rival-machine-profile-ptr! machine (add1 profile-ptr))))
3941

4042
(define (rival-machine-run machine vhint)
4143
(define ivec (rival-machine-instructions machine))

test.rkt

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,7 @@
33
(require racket/math
44
math/base
55
math/flonum
6-
(only-in math/bigfloat
7-
bf>
8-
bf<
9-
bf=
10-
bf>=
11-
bf<=
12-
bf-
13-
bf+
14-
bf*
15-
bf/
16-
bfmin
17-
bfmax
18-
bfshift))
6+
(only-in math/bigfloat bf> bf< bf= bf>= bf<= bf- bf+ bf* bf/ bfmin bfmax bfshift))
197
(require rackunit)
208
(require "main.rkt"
219
"mpfr.rkt")

0 commit comments

Comments
 (0)