Skip to content

Commit bcd6c5e

Browse files
committed
plot updates!
1 parent e179028 commit bcd6c5e

File tree

4 files changed

+110
-2
lines changed

4 files changed

+110
-2
lines changed

infra/cnt_per_iters_plot.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
import argparse
2+
import json
3+
import numpy as np
4+
import pandas as pd
5+
import matplotlib.pyplot as plt
6+
7+
def plot_cnt_per_iters(outcomes, args):
8+
# Create figure
9+
fig, ax = plt.subplots(figsize=(4, 3.5))
10+
fig.tight_layout(pad=2.0)
11+
12+
# Drop precision column and sum up based on iteration
13+
# outcomes = outcomes.drop(['baseline_precision'], axis=1)
14+
# outcomes = outcomes.groupby(['rival_iter', 'tool_name'], as_index=False).sum()
15+
16+
# Select tools
17+
baseline = outcomes.loc[(outcomes['tool_name'] == "valid-baseline") & (outcomes['baseline_precision'] > 73)]
18+
baseline = baseline.drop(['rival_iter'], axis=1)
19+
baseline = baseline.groupby(['baseline_precision'], as_index=False).sum()
20+
21+
rival = outcomes.loc[(outcomes['tool_name'] == "valid-rival") & (outcomes['rival_iter'] > 0)]
22+
rival = rival.drop(['baseline_precision'], axis=1)
23+
rival = rival.groupby(['rival_iter'], as_index=False).sum()
24+
25+
ax.bar(np.arange(len(baseline)) + 0.9, baseline['number_of_points'], color="green", alpha=1, width=0.4, label='baseline', hatch='/')
26+
ax.bar(np.arange(len(rival)) + 1.1, rival['number_of_points'], color="red", alpha=0.7, width=0.4, label='reval')
27+
28+
ax.legend()
29+
ax.set_xlabel("Iteration")
30+
ax.set_ylabel("Count of converged points")
31+
ax.yaxis.grid(True, linestyle='-', which='major', color='grey', alpha=0.3)
32+
plt.tight_layout()
33+
plt.savefig(args.path + "/cnt_per_iters_plot.png", format="png")
34+
plt.savefig(args.path + "/cnt_per_iters_plot.pdf", format="pdf")
35+
36+
def load_outcomes(path):
37+
outcomes = json.load(open(path, "r"))["outcomes"]
38+
outcomes = pd.DataFrame(outcomes, columns=['time', 'rival_iter', 'baseline_precision', 'tool_name', 'number_of_points'])
39+
return outcomes
40+
41+
parser = argparse.ArgumentParser(prog='ratio_plot.py', description='Script outputs ratio plots')
42+
parser.add_argument('-t', '--timeline', dest='timeline', default="report/timeline.json")
43+
parser.add_argument('-o', '--output-path', dest='path', default="report")
44+
args = parser.parse_args()
45+
46+
outcomes = load_outcomes(args.timeline)
47+
plot_cnt_per_iters(outcomes, args)

infra/nightly.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ function perf {
6363
python3 infra/point_graph.py -t "$REPORTDIR"/timeline.json -o "$REPORTDIR"
6464
python3 infra/histograms.py -t "$REPORTDIR"/timeline.json -o "$REPORTDIR"
6565
python3 infra/cnt_per_iters_plot.py -t "$REPORTDIR"/timeline.json -o "$REPORTDIR"
66+
python3 infra/repeats_plot.py -t "$REPORTDIR"/timeline.json -o "$REPORTDIR"
6667
cp profile.json "$REPORTDIR"/profile.json
6768
cp profile.js "$REPORTDIR"/profile.js
6869
}

infra/repeats_plot.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import argparse
2+
import json
3+
import numpy as np
4+
import pandas as pd
5+
import matplotlib.pyplot as plt
6+
7+
def plot_repeats_plot(outcomes, args):
8+
# Create figure
9+
fig, ax = plt.subplots(figsize=(4, 3.5))
10+
fig.tight_layout(pad=2.0)
11+
12+
# Drop precision column and sum up based on iteration
13+
rival = outcomes.loc[(outcomes['tool'] == "rival") & (outcomes['iter'] > 0)]
14+
baseline = outcomes.loc[(outcomes['tool'] == "baseline") & (outcomes['iter'] > 0)]
15+
16+
ax.bar(np.arange(len(baseline)) + 0.9, baseline['number_of_instr_executions'], color="green", alpha=1, width=0.4, label='baseline', hatch='/')
17+
ax.bar(np.arange(len(rival)) + 1.1, rival['number_of_instr_executions'], color="red", alpha=0.7, width=0.4, label='reval')
18+
19+
ax.legend()
20+
ax.set_xlabel("Iteration")
21+
ax.set_ylabel("Number of instructions executions")
22+
ax.yaxis.grid(True, linestyle='-', which='major', color='grey', alpha=0.3)
23+
plt.tight_layout()
24+
plt.savefig(args.path + "/repeats_plot.png", format="png")
25+
plt.savefig(args.path + "/repeats_plot.pdf", format="pdf")
26+
27+
def load_outcomes(path):
28+
outcomes = json.load(open(path, "r"))["instr-executed-cnt"]
29+
outcomes = pd.DataFrame(outcomes, columns=['tool', 'iter', 'number_of_instr_executions'])
30+
return outcomes
31+
32+
parser = argparse.ArgumentParser(prog='repeats_plot.py', description='Script outputs repeats plots')
33+
parser.add_argument('-t', '--timeline', dest='timeline', default="report/timeline.json")
34+
parser.add_argument('-o', '--output-path', dest='path', default="report")
35+
args = parser.parse_args()
36+
37+
outcomes = load_outcomes(args.timeline)
38+
plot_repeats_plot(outcomes, args)
39+

time.rkt

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,12 @@
9090
'mixsample-rival-all
9191
(list (execution-time execution) name precision)))
9292

93+
; Record number of instructions has been executed
94+
(when (equal? rival-status 'valid)
95+
(timeline-push! timeline
96+
'instr-executed-cnt
97+
(list 'rival rival-iter (vector-length rival-executions))))
98+
9399
; --------------------------- Baseline execution ----------------------------------------------
94100
(define baseline-start-apply (current-inexact-milliseconds))
95101
(match-define (list baseline-status baseline-exs)
@@ -117,6 +123,11 @@
117123
'mixsample-baseline-all
118124
(list (execution-time execution) name precision)))
119125

126+
(when (equal? rival-status 'valid)
127+
(timeline-push! timeline
128+
'instr-executed-cnt
129+
(list 'baseline rival-iter (vector-length baseline-executions))))
130+
120131
; --------------------------- Sollya execution ------------------------------------------------
121132
; Points for expressions where Sollya has not compiled do not go to the plot/speed graphs!
122133
; Also, if Rival's status is invalid - these points do not go to the graphs!
@@ -222,6 +233,11 @@
222233
(match-define (list time* name precision) args*)
223234
(define time (hash-ref mixsample-hash (list name precision) (λ () 0)))
224235
(hash-set! mixsample-hash (list name precision) (+ time time*))]
236+
['instr-executed-cnt
237+
(define instr-cnt-hash (hash-ref timeline key))
238+
(match-define (list tool iter cnt) args*)
239+
(define cnt* (hash-ref instr-cnt-hash (list tool iter) (λ () 0)))
240+
(hash-set! instr-cnt-hash (list tool iter) (+ cnt cnt*))]
225241
[else (error "Unknown key for timeline!")]))
226242

227243
(define (timeline->jsexpr timeline)
@@ -239,7 +255,10 @@
239255
(list value (car key) (second key)))
240256
'mixsample-baseline-all
241257
(for/list ([(key value) (in-hash (hash-ref timeline 'mixsample-baseline-all))])
242-
(list value (car key) (second key)))))
258+
(list value (car key) (second key)))
259+
'instr-executed-cnt
260+
(for/list ([(key value) (in-hash (hash-ref timeline 'instr-executed-cnt))])
261+
(list (~a (car key)) (second key) value))))
243262

244263
(define (make-expression-table points test-id timeline-port)
245264
(newline)
@@ -257,7 +276,8 @@
257276
(cons 'mixsample-rival-valid (make-hash))
258277
(cons 'mixsample-baseline-valid (make-hash))
259278
(cons 'mixsample-rival-all (make-hash))
260-
(cons 'mixsample-baseline-all (make-hash)))))
279+
(cons 'mixsample-baseline-all (make-hash))
280+
(cons 'instr-executed-cnt (make-hash)))))
261281

262282
(define table
263283
(for/list ([rec (in-port read-json points)]
@@ -404,6 +424,7 @@
404424
(html-add-plot html-port "ratio_plot_precision.png")
405425
(html-add-plot html-port "point_graph.png")
406426
(html-add-plot html-port "cnt_per_iters_plot.png")
427+
(html-add-plot html-port "repeats_plot.png")
407428
(html-add-histogram html-port "histogram_valid.png")
408429
(html-add-histogram html-port "histogram_all.png"))
409430

0 commit comments

Comments
 (0)