Skip to content

Commit 340f5e0

Browse files
authored
Merge pull request #1392 from herbie-fp/rival-memory-profile
Include rival memory profile in report
2 parents d8e79d5 + 9c95e81 commit 340f5e0

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/core/rival.rkt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,11 @@
128128
(define name (symbol->string (execution-name execution)))
129129
(define precision
130130
(- (execution-precision execution) (remainder (execution-precision execution) prec-threshold)))
131-
(timeline-push!/unsafe 'mixsample (execution-time execution) name precision))
131+
(timeline-push!/unsafe 'mixsample
132+
(execution-time execution)
133+
name
134+
precision
135+
(execution-memory execution)))
132136
(timeline-push!/unsafe 'outcomes
133137
(- (current-inexact-milliseconds) start)
134138
(rival-profile machine 'iterations)

src/reports/timeline.rkt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,8 @@
162162

163163
(define (render-phase-mixed-sampling mixsample)
164164
(define total-time (apply + (map first mixsample)))
165+
(define (format-memory-bytes bytes)
166+
(format "~a MiB" (~r (/ bytes (expt 2 20)) #:precision '(= 1))))
165167
`((dt "Precisions")
166168
(dd (details
167169
(summary "Click to see histograms. Total time spent on operations: "
@@ -173,14 +175,19 @@
173175
(define op (second (car rec)))
174176
(define precisions (map third rec))
175177
(define times (map first rec))
178+
(define memories (map fourth rec))
179+
176180
(define time-per-op (round (apply + times)))
181+
(define memory-per-op (apply + memories))
177182

178183
(list `(details (summary (code ,op)
179184
": "
180185
,(format-time time-per-op)
181186
" ("
182187
,(format-percent time-per-op total-time)
183-
" of total)")
188+
" of total, "
189+
,(format-memory-bytes memory-per-op)
190+
")")
184191
(canvas ([id ,(format "calls-~a" n)]
185192
[title
186193
"Histogram of precisions of the used operation"]))

src/utils/timeline.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186

187187
(define-timeline memory [live +] [alloc +])
188188
(define-timeline method [method])
189-
(define-timeline mixsample [time +] [function false] [precision false])
189+
(define-timeline mixsample [time +] [function false] [precision false] [memory +])
190190
(define-timeline times [time +] [input false])
191191
(define-timeline series [time +] [var false] [transform false])
192192
(define-timeline compiler [before +] [after +])

0 commit comments

Comments
 (0)