mirror of
https://github.com/ivanch/tcc.git
synced 2025-08-25 07:11:50 +00:00
adding protobuf
This commit is contained in:
@@ -1,9 +1,14 @@
|
||||
import helloworld_pb2
|
||||
|
||||
helloworld = helloworld_pb2.MyObj()
|
||||
helloworld.message = "Hello World!"
|
||||
|
||||
FRAMEWORKS = [
|
||||
('Actix', 'tcc-actix', 'orange'),
|
||||
('ASP.NET', 'tcc-aspnet', 'blue'),
|
||||
('Flask', 'tcc-flask', 'green'),
|
||||
('Flask', 'tcc-flask', 'grey'),
|
||||
('Express', 'tcc-express', 'red'),
|
||||
('Spring', 'tcc-spring', 'pink'),
|
||||
('Spring', 'tcc-spring', 'green'),
|
||||
]
|
||||
|
||||
ENDPOINTS = {
|
||||
@@ -15,15 +20,16 @@ ENDPOINTS = {
|
||||
}
|
||||
|
||||
AVG_RUNS = 5
|
||||
|
||||
helloworld_pb2
|
||||
API_REQUESTS = [
|
||||
('/status/ok', 'GET', range(0, 30_000, 5000), None),
|
||||
('/simulation/harmonic-progression?n=100000', 'GET', range(0, 30_000, 5000), None),
|
||||
('/simulation/json', 'GET', range(0, 30_000, 5000), None),
|
||||
('/image/save-big-image', 'POST', range(0, 500, 50), open('big-image.png', 'rb').read()),
|
||||
('/image/load-small-image', 'GET', range(0, 30_000, 5000), None),
|
||||
('/static/small-image.png', 'GET', range(0, 30_000, 5000), None),
|
||||
('/image/load-big-image', 'GET', range(0, 500, 50), None),
|
||||
('/static/big-image.png', 'GET', range(0, 500, 50), None),
|
||||
('/static/nginx.html', 'GET', range(0, 30_000, 5000), None),
|
||||
# ('/simulation/harmonic-progression?n=100000', 'GET', range(0, 30_000, 5000), None),
|
||||
# ('/simulation/json', 'GET', range(0, 30_000, 5000), None),
|
||||
# ('/image/save-big-image', 'POST', range(0, 500, 50), open('big-image.png', 'rb').read()),
|
||||
# ('/image/load-small-image', 'GET', range(0, 30_000, 5000), None),
|
||||
# ('/static/small-image.png', 'GET', range(0, 30_000, 5000), None),
|
||||
# ('/image/load-big-image', 'GET', range(0, 500, 50), None),
|
||||
# ('/static/big-image.png', 'GET', range(0, 500, 50), None),
|
||||
# ('/static/nginx.html', 'GET', range(0, 30_000, 5000), None),
|
||||
('/simulation/protobuf', 'POST', range(0, 30_000, 5000), helloworld.SerializeToString()),
|
||||
]
|
||||
|
@@ -10,6 +10,17 @@ FRAMEWORKS = [f for f, _, _ in FRAMEWORKS]
|
||||
def setBoxColors(bp):
|
||||
for i, box in enumerate(bp['boxes']):
|
||||
box.set(color=FRAMEWORKS_COLORS[i])
|
||||
for i, median in enumerate(bp['medians']):
|
||||
# median.set(color=FRAMEWORKS_COLORS[i])
|
||||
median.set(color='white')
|
||||
|
||||
for i in range(len(FRAMEWORKS)):
|
||||
bp['whiskers'][i*2].set(color=FRAMEWORKS_COLORS[i])
|
||||
bp['whiskers'][i*2 + 1].set(color=FRAMEWORKS_COLORS[i])
|
||||
for i in range(len(FRAMEWORKS)):
|
||||
bp['caps'][i*2].set(color=FRAMEWORKS_COLORS[i])
|
||||
bp['caps'][i*2 + 1].set(color=FRAMEWORKS_COLORS[i])
|
||||
|
||||
|
||||
def plot_graph(x_data, y_data, title, x_label, y_label, filename, y_lim = None):
|
||||
old_x_data = x_data
|
||||
@@ -22,10 +33,10 @@ def plot_graph(x_data, y_data, title, x_label, y_label, filename, y_lim = None):
|
||||
if old_x_data[i] not in x_data:
|
||||
x_data.append(old_x_data[i])
|
||||
y_data.append([])
|
||||
for f in range(2):
|
||||
for f in range(len(FRAMEWORKS)):
|
||||
y_data[-1].append([])
|
||||
|
||||
for f in range(2):
|
||||
for f in range(len(FRAMEWORKS)):
|
||||
y_data[-1][f].append(old_y_data[f][i])
|
||||
|
||||
fig = figure()
|
||||
@@ -33,15 +44,28 @@ def plot_graph(x_data, y_data, title, x_label, y_label, filename, y_lim = None):
|
||||
|
||||
all_positions = []
|
||||
|
||||
print(filename)
|
||||
# print(y_data)
|
||||
for j in range(len(x_data)):
|
||||
positions = [len(FRAMEWORKS)*j + i + 1 for i in range(len(FRAMEWORKS))]
|
||||
bp = boxplot(y_data[j], positions = positions, widths = 0.6)
|
||||
positions = [len(FRAMEWORKS)*j + i + 2*j for i in range(len(FRAMEWORKS))]
|
||||
|
||||
bp = boxplot(y_data[j], positions = positions, widths = 0.6, showfliers=False,
|
||||
patch_artist=True)
|
||||
all_positions.append(positions)
|
||||
setBoxColors(bp)
|
||||
|
||||
for i in range(len(FRAMEWORKS)):
|
||||
medians = []
|
||||
for j in range(len(x_data)):
|
||||
medians.append(np.median(y_data[j][i]))
|
||||
|
||||
positions = [all_positions[x][i] for x in range(len(x_data))]
|
||||
plt.plot(positions, medians, color=FRAMEWORKS_COLORS[i], marker='.', linestyle='--', linewidth=0.3)
|
||||
|
||||
avg_positions = []
|
||||
for positions in all_positions:
|
||||
avg_positions.append(np.average(positions))
|
||||
avg = np.average(positions)
|
||||
avg_positions.append(avg)
|
||||
|
||||
ax.set_xticks(avg_positions)
|
||||
ax.set_xticklabels([str(x) for x in x_data])
|
||||
@@ -53,11 +77,14 @@ def plot_graph(x_data, y_data, title, x_label, y_label, filename, y_lim = None):
|
||||
if y_lim:
|
||||
plt.ylim(y_lim)
|
||||
|
||||
for i, framework in enumerate(FRAMEWORKS):
|
||||
h, = plt.plot([], c=FRAMEWORKS_COLORS[i], label=framework)
|
||||
# h.set_visible(False)
|
||||
if filename.startswith('req'):
|
||||
for i, framework in enumerate(FRAMEWORKS):
|
||||
h, = plt.plot([], c=FRAMEWORKS_COLORS[i], label=framework, marker='.', linestyle='--')
|
||||
# h.set_visible(False)
|
||||
|
||||
plt.legend()
|
||||
plt.legend()
|
||||
|
||||
plt.tight_layout()
|
||||
plt.savefig(f'{filename}.png')
|
||||
|
||||
plt.clf()
|
||||
@@ -134,6 +161,8 @@ if __name__ == '__main__':
|
||||
framework_name = 'ASP.NET'
|
||||
endpoint_file = endpoint_name.replace('/', '')
|
||||
|
||||
endpoint_name = '/' + endpoint_name.split('/')[-1]
|
||||
|
||||
filename = f'data/resource_ASP.NET_{endpoint_file}.csv'
|
||||
filename = filename.replace("?", "_")
|
||||
generate_resource_graph(filename, framework_name, endpoint_name)
|
||||
|
5
scripts/helloworld.proto
Normal file
5
scripts/helloworld.proto
Normal file
@@ -0,0 +1,5 @@
|
||||
syntax = "proto3";
|
||||
|
||||
message MyObj {
|
||||
string message = 1;
|
||||
}
|
26
scripts/helloworld_pb2.py
Normal file
26
scripts/helloworld_pb2.py
Normal file
@@ -0,0 +1,26 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# Generated by the protocol buffer compiler. DO NOT EDIT!
|
||||
# source: helloworld.proto
|
||||
# Protobuf Python Version: 4.25.0
|
||||
"""Generated protocol buffer code."""
|
||||
from google.protobuf import descriptor as _descriptor
|
||||
from google.protobuf import descriptor_pool as _descriptor_pool
|
||||
from google.protobuf import symbol_database as _symbol_database
|
||||
from google.protobuf.internal import builder as _builder
|
||||
# @@protoc_insertion_point(imports)
|
||||
|
||||
_sym_db = _symbol_database.Default()
|
||||
|
||||
|
||||
|
||||
|
||||
DESCRIPTOR = _descriptor_pool.Default().AddSerializedFile(b'\n\x10helloworld.proto\"\x18\n\x05MyObj\x12\x0f\n\x07message\x18\x01 \x01(\tb\x06proto3')
|
||||
|
||||
_globals = globals()
|
||||
_builder.BuildMessageAndEnumDescriptors(DESCRIPTOR, _globals)
|
||||
_builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, 'helloworld_pb2', _globals)
|
||||
if _descriptor._USE_C_DESCRIPTORS == False:
|
||||
DESCRIPTOR._options = None
|
||||
_globals['_MYOBJ']._serialized_start=20
|
||||
_globals['_MYOBJ']._serialized_end=44
|
||||
# @@protoc_insertion_point(module_scope)
|
Reference in New Issue
Block a user