xref: /aosp_15_r20/external/aws-sdk-java-v2/test/s3-benchmarks/.scripts/plot.py (revision 8a52c7834d808308836a99fc2a6e0ed8db339086)
1#!bin/python3
2
3import os
4import plotly.graph_objects as go
5from functools import reduce
6
7def spread(amount, arr):
8    """
9    duplicate elements of the array by the amount.
10    Ex.: spread(3, ["a", "b"]) -> ["a", "a", "a", "b", "b", "b"]
11    """
12    return reduce(lambda x, y: x+y, map(lambda e: ([e] * amount), arr))
13
14# 8x6 matrices where each row is all the attempt for the same benchmark
15data_single_file = {
16    'copy': {
17        'v1': [
18            # 1B
19            0.036, 0.04, 0.044, 0.036, 0.037, 0.036, 0.043, 0.037,
20            # 8MB-1
21            0.042, 0.039, 0.043, 0.05, 0.043, 0.049, 0.055, 0.045,
22            # 8MB+1
23            0.06, 0.06, 0.094, 0.076, 0.045, 0.077, 0.062, 0.071,
24            # 128MB
25            0.832, 0.869, 0.842, 0.739, 0.892, 0.784, 0.772, 0.904,
26            # 4GB
27            34.113, 37.754, 36.9, 36.369, 35.358, 34.21, 36.525, 44.225,
28            # 30GB
29            6.463, 5.726, 5.994, 9.275, 10.091, 5.152, 5.85, 6.524
30        ],
31        'v2': [
32            1.053, 0.056, 0.043, 0.066, 0.056, 0.056, 0.045, 0.045,
33            0.058, 0.062, 0.071, 0.069, 0.066, 0.066, 0.074, 0.166,
34            0.095, 0.072, 0.088, 0.135, 0.088, 0.076, 0.068, 0.105,
35            0.371, 1.886, 5.315, 0.4, 0.367, 2.364, 0.387, 0.42,
36            3.565, 3.869, 3.789, 2.447, 5.423, 2.046, 5.478, 5.175,
37            7.366, 7.946, 8.59, 8.243, 8.332, 7.607, 7.606, 8.041
38        ],
39    },
40    'download': {
41        'disk': {
42            'v1': [
43                0.025, 0.025, 0.024, 0.042, 0.026, 0.023, 0.024, 0.025,
44                0.187, 0.117, 0.136, 0.113, 0.117, 0.116, 0.113, 0.114,
45                0.306, 0.144, 0.248, 0.122, 0.116, 0.115, 0.113, 0.148,
46                0.499, 0.344, 0.273, 0.286, 0.332, 0.447, 0.348, 0.29,
47                3.139, 2.811, 2.571, 2.509, 2.724, 2.484, 2.522, 2.563,
48                52.904, 52.058, 45.316, 44.583, 50.343, 50.369, 53.261, 47.356
49            ],
50            'v2': [
51                0.031, 0.04, 0.036, 0.027, 0.037, 0.049, 0.042, 0.026,
52                0.166, 0.13, 0.105, 0.122, 0.108, 0.118, 0.12, 0.111,
53                0.201, 0.133, 0.233, 0.13, 0.122, 0.122, 0.117, 0.126,
54                0.334, 0.241, 0.186, 0.184, 0.194, 0.239, 0.236, 0.191,
55                1.628, 1.565, 1.367, 1.641, 1.488, 1.353, 1.423, 1.451,
56                23.328, 25.317, 26.666, 25.147, 25.899, 25.879, 23.408, 26.406
57            ]
58        },
59        'tmpfs': {
60            'v1': [
61                0.038, 0.034, 0.032, 0.034, 0.032, 0.031, 0.03, 0.044,
62                0.178, 0.113, 0.113, 0.114, 0.114, 0.113, 0.121, 0.113,
63                0.211, 0.135, 0.116, 0.114, 0.114, 0.114, 0.115, 0.113,
64                0.455, 0.372, 0.278, 0.258, 0.258, 0.255, 0.275, 0.256,
65                2.474, 2.392, 2.377, 2.472, 2.511, 2.554, 2.547, 2.579,
66                45.586, 44.304, 43.423, 46.81, 51.413, 50.372, 49.704, 42.938
67            ],
68            'v2': [
69                0.046, 0.021, 0.041, 0.024, 0.026, 0.149, 0.026, 0.026,
70                0.178, 0.12, 0.123, 0.117, 0.125, 0.124, 0.122, 0.152,
71                0.202, 0.198, 0.122, 0.127, 0.108, 0.109, 0.14, 0.12,
72                0.352, 0.274, 0.183, 0.193, 0.202, 0.199, 0.191, 0.191,
73                1.493, 1.373, 1.345, 1.459, 1.474, 1.453, 1.393, 1.353,
74                17.945, 17.071, 16.921, 17.742, 17.338, 21.262, 20.168, 19.728
75            ]
76        }
77    },
78    'upload': {
79        'disk': {
80            'v1': [
81                0.032, 0.02, 0.018, 0.018, 0.017, 0.018, 0.019, 0.018,
82                0.227, 0.143, 0.146, 0.171, 0.165, 0.142, 0.139, 0.129,
83                0.145, 0.15, 0.129, 0.149, 0.153, 0.15, 0.171, 0.126,
84                0.398, 0.362, 0.318, 0.334, 0.351, 3.419, 0.339, 0.287,
85                6.058, 6.073, 1.941, 1.943, 3.692, 5.452, 5.313, 5.935,
86                10.684, 10.801, 10.221, 12.64, 11.778, 12.351, 10.516, 12.691,
87
88            ],
89            'v2': [
90                0.02, 0.019, 0.029, 0.029, 0.035, 0.023, 0.03, 0.034,
91                0.267, 0.417, 0.2, 0.287, 0.252, 0.253, 0.27, 0.29,
92                0.218, 0.283, 0.294, 0.266, 0.359, 0.272, 0.318, 0.236,
93                0.468, 0.487, 0.509, 0.559, 0.55, 0.497, 0.44, 0.476,
94                4.037, 5.459, 5.771, 2.844, 2.987, 5.337, 2.614, 5.106,
95                37.123, 37.304, 38.615, 32.718, 37.608, 40.833, 48.343, 39.442
96            ]
97        },
98        'tmpfs': {
99            'v1': [
100                0.037, 0.018, 0.015, 0.02, 0.015, 0.021, 0.016, 0.02,
101                0.25, 0.161, 0.172, 0.153, 0.602, 0.145, 0.221, 0.173,
102                0.178, 0.161, 0.206, 0.156, 0.196, 0.157, 0.165, 0.171,
103                0.476, 0.353, 0.355, 1.103, 0.325, 0.351, 0.324, 0.68,
104                1.202, 3.178, 0.903, 4.687, 0.744, 2.987, 5.67, 0.91,
105                11.233, 10.044, 8.174, 7.526, 9.358, 10.046, 9.606, 10.037
106            ],
107            'v2': [
108                0.033, 0.031, 0.025, 0.034, 0.034, 0.03, 0.033, 0.041,
109                0.267, 0.31, 0.316, 0.264, 0.302, 0.286, 0.269, 0.268,
110                0.236, 0.293, 0.315, 0.293, 0.252, 0.266, 0.249, 0.317,
111                0.582, 0.487, 0.547, 0.465, 0.46, 0.445, 0.621, 0.468,
112                2.394, 2.434, 2.476, 4.944, 3.26, 2.454, 2.468, 2.397,
113                33.261, 41.114, 33.014, 32.97, 34.138, 33.972, 33.001, 34.12
114            ]
115        }
116    }
117}
118
119# 8x3 matrices where each row is all the attempt for the same benchmark
120data_directory = {
121    'download': {
122        "disk": {
123            "v1": [
124                # 1Bx1000
125                24.68, 20.315, 19.796, 17.808, 16.791, 18.575, 19.795, 19.865,
126                # 4Kx1000
127                20.448, 19.639, 17.199, 19.143, 20.359, 19.607, 20.298, 19.523,
128                # 16Mx1000
129                15.236, 15.127, 15.62, 16.003, 16.594, 17.597, 17.261, 17.779
130            ],
131            "v2": [
132                0.624, 0.427, 0.435, 0.449, 0.416, 0.414, 0.517, 0.429,
133                0.617, 0.48, 0.519, 0.432, 0.403, 0.411, 0.463, 0.402,
134                3.291, 2.619, 2.698, 2.488, 2.618, 2.473, 2.428, 2.487
135            ]
136        },
137        "tmpfs": {
138            "v1": [
139                19.468, 19.334, 19.428, 18.189, 17.86, 17.717, 17.384, 18.513,
140                22.286, 18.909, 19.058, 19.645, 19.646, 20.196, 19.321, 19.678,
141                17.807, 16.571, 16.324, 15.872, 16.626, 16.139, 16.437, 16.003
142            ],
143            "v2": [
144                0.607, 0.474, 0.432, 0.392, 0.427, 0.359, 0.357, 0.323,
145                0.633, 0.447, 0.476, 0.429, 0.398, 0.413, 0.476, 0.381,
146                3.028, 2.692, 2.667, 2.543, 2.632, 2.578, 2.585, 2.492
147            ]
148        }
149    },
150    'upload': {
151        "disk": {
152            "v1": [
153                0.341, 0.448, 0.487, 0.947, 0.304, 0.261, 0.297, 0.301,
154                3.949, 0.392, 3.71, 1.005, 0.371, 0.354, 0.389, 0.371,
155                8.009, 6.948, 7.37, 5.141, 3.546, 4.866, 4.325, 5.609
156            ],
157            "v2": [
158                4.057, 3.504, 3.361, 3.363, 3.337, 3.319, 3.334, 3.305,
159                4.124, 3.671, 3.582, 3.655, 3.481, 3.659, 3.434, 3.463,
160                5.349, 9.489, 7.626, 7.471, 9.632, 7.452, 7.21, 7.082
161            ]
162        },
163        "tmpfs": {
164            "v1": [
165                0.274, 0.212, 0.224, 0.24, 0.244, 0.222, 0.216, 0.239,
166                0.384, 0.364, 0.363, 0.329, 0.349, 0.411, 0.392, 0.347,
167                6.916, 6.307, 6.492, 8.0, 7.968, 7.322, 4.969, 6.121
168            ],
169            "v2": [
170                3.547, 3.212, 3.191, 3.068, 3.036, 3.015, 3.116, 3.069,
171                4.091, 3.563, 3.495, 3.435, 3.468, 3.434, 3.479, 3.408,
172                5.531, 6.018, 5.639, 8.545, 5.927, 8.506, 6.945, 8.973
173            ]
174        }
175    }
176}
177
178directory_sizes   = spread(8, [ "1Bx1000", "4Kx1000", "16Mx1000" ])
179single_file_sizes = spread(8, [ "1B", "8MB-1", "8MB+1", "128MB", "4GB", "30GB" ])
180
181v1_color = 'rgb(116, 116, 116)'
182v2_color = 'rgb(21, 21, 21)'
183
184def bar_graph(name, sizes, data, log_y_axis=True):
185    figure = go.Figure()
186    figure.add_trace(go.Box(
187        y=data['v1'],
188        x=sizes,
189        name='v1',
190        marker_color=v1_color,
191        boxpoints=False,
192        boxmean=True,
193        line_width=0.8
194    ))
195    figure.add_trace(go.Box(
196        y=data['v2'],
197        x=sizes,
198        name='v2',
199        marker_color=v2_color,
200        boxmean=True,
201        boxpoints=False,
202        line_width=0.8
203    ))
204    if log_y_axis:
205        figure.update_yaxes(type="log")
206    figure.update_layout(
207        title=name,
208        yaxis_title='seconds',
209        boxmode='group'
210    )
211    return figure
212
213if not os.path.exists("../images"):
214    os.mkdir("../images")
215
216bar_graph("upload-tmpfs", single_file_sizes, data_single_file['upload']['tmpfs']).write_image("../images/upload-tmpfs.png")
217bar_graph("upload-disk", single_file_sizes, data_single_file['upload']['disk']).write_image("../images/upload-disk.png")
218bar_graph("download-tmpfs", single_file_sizes, data_single_file['download']['tmpfs']).write_image("../images/download-tmpfs.png")
219bar_graph("download-disk", single_file_sizes, data_single_file['download']['disk']).write_image("../images/download-disk.png")
220bar_graph("copy", single_file_sizes, data_single_file['copy']).write_image("../images/copy.png")
221
222bar_graph("download-directory-tmpfs", directory_sizes, data_directory['download']['tmpfs']).write_image("../images/download-directory-tmpfs.png")
223bar_graph("download-directory-disk", directory_sizes, data_directory['download']['disk']).write_image("../images/download-directory-disk.png")
224bar_graph("upload-directory-tmpfs", directory_sizes, data_directory['upload']['tmpfs']).write_image("../images/upload-directory-tmpfs.png")
225bar_graph("upload-directory-disk", directory_sizes, data_directory['upload']['disk']).write_image("../images/upload-directory-disk.png")
226