1
+ import pandas as pd
2
+ import random
3
+ import matplotlib .pyplot as plt
4
+ from matplotlib .ticker import FormatStrFormatter
5
+ from matplotlib .colors import ListedColormap
6
+ from matplotlib .backends .backend_pdf import PdfPages
7
+
8
+ inputFile = "jmh-result.csv"
9
+ outputFile = "flatten-merge-plots.pdf"
10
+ 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 ()
37
+ for flows in data .flows .unique ():
38
+ genColour = next (colourGen )
39
+ genMarker = next (markerGen )
40
+ res = data [(data .flows == flows )]
41
+ ax .plot (res .concurrency , res .score * elements , label = "flows={}" .format (flows ), color = genColour , marker = genMarker )
42
+
43
+ def genFile (pdf ):
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
+
50
+ plt .tight_layout (pad = 12 , w_pad = 2 , h_pad = 1 )
51
+ pdf .savefig (bbox_inches = 'tight' )
52
+
53
+ with PdfPages (outputFile ) as pdf :
54
+ genFile (pdf )
0 commit comments