1
1
import pandas as pd
2
- import random
3
2
import matplotlib .pyplot as plt
4
3
from matplotlib .ticker import FormatStrFormatter
5
- from matplotlib .colors import ListedColormap
6
- from matplotlib .backends .backend_pdf import PdfPages
7
4
8
5
inputFile = "jmh-result.csv"
9
- outputFile = "flatten-merge-plots.pdf "
6
+ outputFile = "flatten-merge-plots.svg "
10
7
elements = 10000
11
- flattenMergeBenchmarkName = "benchmarks.flow.FlattenMergeBenchmark.flattenMerge"
12
-
13
- def nextColour ():
14
- colours = ['black' , 'silver' , 'red' , 'gold' , 'sienna' , 'olivedrab' , 'lightseagreen' , 'navy' , 'blue' , 'm' , 'crimson' , 'yellow' , 'orangered' , 'slateblue' , 'aqua' ]
15
-
16
- for colour in colours :
17
- yield colour
18
-
19
- def nextMarker ():
20
- markers = ['.' , 'v' , '^' , '1' , '2' , '8' , 'p' , 'P' , 'x' , 'D' , 'd' , 's' ]
21
-
22
- for marker in markers :
23
- yield marker
24
-
25
- def draw (data , ax ):
26
- data = data [(data .benchmark == flattenMergeBenchmarkName )]
27
-
28
- ax .set_xscale ('log' , basex = 2 )
29
- ax .xaxis .set_major_formatter (FormatStrFormatter ('%0.f' ))
30
- ax .grid (linewidth = '0.5' , color = 'lightgray' )
31
- ax .set_ylabel (data .unit .unique ()[0 ])
32
- ax .set_xlabel ('parallelism' )
33
- ax .set_xticks (data .concurrency .unique ())
34
-
35
- colourGen = nextColour ()
36
- markerGen = nextMarker ()
8
+ benchmarkName = "benchmarks.flow.FlattenMergeBenchmark.flattenMerge"
9
+
10
+ markers = ['.' , 'v' , '^' , '1' , '2' , '8' , 'p' , 'P' , 'x' , 'D' , 'd' , 's' ]
11
+ colours = ['black' , 'silver' , 'red' , 'gold' , 'sienna' , 'olivedrab' , 'lightseagreen' , 'navy' , 'blue' , 'm' , 'crimson' , 'yellow' , 'orangered' , 'slateblue' , 'aqua' ]
12
+
13
+ def next_colour ():
14
+ i = 0
15
+ while True :
16
+ yield colours [i % len (colours )]
17
+ i += 1
18
+
19
+ def next_marker ():
20
+ i = 0
21
+ while True :
22
+ yield markers [i % len (markers )]
23
+ i += 1
24
+
25
+ def draw (data , plt ):
26
+ data = data [(data .benchmark == benchmarkName )]
27
+
28
+ plt .xscale ('log' , basex = 2 )
29
+ plt .gca ().xaxis .set_major_formatter (FormatStrFormatter ('%0.f' ))
30
+ plt .grid (linewidth = '0.5' , color = 'lightgray' )
31
+ plt .ylabel (data .unit .unique ()[0 ])
32
+ plt .xlabel ('parallelism' )
33
+ plt .xticks (data .concurrency .unique ())
34
+
35
+ colourGen = next_colour ()
36
+ markerGen = next_marker ()
37
37
for flows in data .flows .unique ():
38
38
genColour = next (colourGen )
39
39
genMarker = next (markerGen )
40
40
res = data [(data .flows == flows )]
41
- ax .plot (res .concurrency , res .score * elements , label = "flows={}" .format (flows ), color = genColour , marker = genMarker )
41
+ plt .plot (res .concurrency , res .score * elements , label = "flows={}" .format (flows ), color = genColour , marker = genMarker )
42
42
43
- def genFile (pdf ):
43
+ def genFile ():
44
44
data = pd .read_table (inputFile , sep = "," , skiprows = 1 , names = ["benchmark" ,"mode" ,"threads" ,"samples" ,"score" ,"scoreError" ,"unit" ,"concurrency" ,"flows" ])
45
- fig , ax = plt .subplots (nrows = 1 , ncols = 1 , figsize = (20 , 20 ))
46
- draw (data , ax )
47
- lines , labels = ax .get_legend_handles_labels ()
48
- fig .legend (lines , labels , loc = 'upper center' , borderpad = 0 , ncol = 4 , frameon = False , borderaxespad = 4 , prop = {'size' : 8 })
49
-
45
+ plt .figure (figsize = (20 , 20 ))
46
+ draw (data , plt )
47
+ plt .legend (loc = 'upper center' , borderpad = 0 , ncol = 4 , frameon = False , borderaxespad = 4 , prop = {'size' : 8 })
50
48
plt .tight_layout (pad = 12 , w_pad = 2 , h_pad = 1 )
51
- pdf .savefig (bbox_inches = 'tight' )
49
+ plt .savefig (outputFile , bbox_inches = 'tight' )
52
50
53
- with PdfPages (outputFile ) as pdf :
54
- genFile (pdf )
51
+ genFile ()
0 commit comments