mirror of https://github.com/ivanch/tcc.git
Compare commits
No commits in common. "274fe5252a283d2d3cba242f1e19ceac7c309660" and "ed9942d56e08131bf64288e273f4f38ffef05f07" have entirely different histories.
274fe5252a
...
ed9942d56e
|
@ -15,6 +15,18 @@ namespace TCC.Controllers
|
|||
this.ImageService = imageService;
|
||||
}
|
||||
|
||||
[HttpGet("load-small-image")]
|
||||
public async Task<IActionResult> GetSimpleImage()
|
||||
{
|
||||
return File(ImageService.GetSimpleImage(), "image/png");
|
||||
}
|
||||
|
||||
[HttpGet("load-big-image")]
|
||||
public async Task<IActionResult> GetBigImage()
|
||||
{
|
||||
return File(ImageService.GetBigImage(), "image/png");
|
||||
}
|
||||
|
||||
[HttpPost("save-big-image")]
|
||||
public async Task<IActionResult> SaveBigImage()
|
||||
{
|
||||
|
|
|
@ -10,5 +10,15 @@
|
|||
fileStream.CopyToAsync(file);
|
||||
file.Close();
|
||||
}
|
||||
|
||||
public byte[] GetSimpleImage()
|
||||
{
|
||||
return File.ReadAllBytes("static/small-image.png");
|
||||
}
|
||||
|
||||
public byte[] GetBigImage()
|
||||
{
|
||||
return File.ReadAllBytes("static/big-image.png");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
FROM rust:1.77-buster as builder
|
||||
WORKDIR /app
|
||||
COPY . .
|
||||
RUN cargo build --release
|
||||
FROM rust:latest
|
||||
|
||||
FROM debian:bullseye-slim
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get -y install wget && \
|
||||
|
@ -11,12 +7,17 @@ RUN apt-get update && apt-get -y install wget && \
|
|||
wget https://files.ivanch.me/api/public/dl/jNlXYMLR/big-image.png && \
|
||||
wget https://files.ivanch.me/api/public/dl/QdKvaeQI/video.mp4 && \
|
||||
wget https://files.ivanch.me/api/public/dl/YD4vmSsO/nginx.html && \
|
||||
mkdir -p ./static && \
|
||||
|
||||
COPY . .
|
||||
|
||||
RUN cargo build --release && \
|
||||
cp ./target/release/ActixAPI . && \
|
||||
mv small-image.png ./static && \
|
||||
mv big-image.png ./static && \
|
||||
mv video.mp4 ./static && \
|
||||
mv nginx.html ./static
|
||||
mv nginx.html ./static && \
|
||||
ldconfig /usr/local/lib
|
||||
|
||||
COPY --from=builder /app/target/release/ActixAPI .
|
||||
ENV LD_LIBRARY_PATH=/usr/local/lib
|
||||
|
||||
CMD ["./ActixAPI"]
|
||||
ENTRYPOINT ["./ActixAPI"]
|
||||
|
|
|
@ -64,10 +64,26 @@ async fn simulation_protobuf(msg: ProtoBuf<PersonProtobuf>) -> impl Responder {
|
|||
HttpResponse::Ok().protobuf(msg.0)
|
||||
}
|
||||
|
||||
#[get("/image/load-small-image")]
|
||||
async fn load_small_image() -> Result<NamedFile> {
|
||||
let real_path = "static/small-image.png";
|
||||
|
||||
Ok(NamedFile::open(real_path)?)
|
||||
}
|
||||
|
||||
#[get("/image/load-big-image")]
|
||||
async fn load_big_image() -> Result<NamedFile> {
|
||||
let real_path = "static/big-image.png";
|
||||
|
||||
Ok(NamedFile::open(real_path)?)
|
||||
}
|
||||
|
||||
#[post("/image/save-big-image")]
|
||||
async fn save_big_image(image_data: web::Bytes) -> Result<HttpResponse> {
|
||||
// Write bytes to file
|
||||
std::fs::write("image.png", &image_data).unwrap();
|
||||
|
||||
// Return the blurred image bytes
|
||||
Ok(HttpResponse::Ok()
|
||||
.content_type("application/json")
|
||||
.body("{\"status\": 200}"))
|
||||
|
@ -81,6 +97,8 @@ async fn main() -> std::io::Result<()> {
|
|||
App::new()
|
||||
.route("/static/{filename:.*}", web::get().to(static_serve))
|
||||
.service(hello)
|
||||
.service(load_small_image)
|
||||
.service(load_big_image)
|
||||
.service(save_big_image)
|
||||
.service(simulation_harmonic_progression)
|
||||
.service(simulation_json)
|
||||
|
|
2
Express
2
Express
|
@ -1 +1 @@
|
|||
Subproject commit 930a322dfac69d25aa2b91ed478c2c4d46bfc68d
|
||||
Subproject commit 3a54792794728b10b2f49bd47dbd7430da811bdd
|
|
@ -5,6 +5,22 @@ from flask import request, Response, Blueprint, jsonify, send_file
|
|||
image_blueprint = Blueprint('image_blueprint', __name__)
|
||||
image_service = ImageService()
|
||||
|
||||
@image_blueprint.route('/image/load-small-image', methods=['GET'])
|
||||
def get_simple_image():
|
||||
return send_file(io.BytesIO(image_service.get_simple_image()),
|
||||
mimetype='image/png',
|
||||
as_attachment=True,
|
||||
download_name='small-image.png')
|
||||
|
||||
|
||||
@image_blueprint.route('/image/load-big-image', methods=['GET'])
|
||||
def get_big_image():
|
||||
return send_file(io.BytesIO(image_service.get_big_image()),
|
||||
mimetype='image/png',
|
||||
as_attachment=True,
|
||||
download_name='big-image.png')
|
||||
|
||||
|
||||
@image_blueprint.route('/image/save-big-image', methods=['POST'])
|
||||
def save_image():
|
||||
image_service.save_image(request.get_data())
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
Flask==3.0
|
||||
gunicorn==19.9.0
|
||||
protobuf==4.25.0
|
||||
Flask>=1.0
|
||||
gunicorn>=19.9.0
|
||||
protobuf>=4.25.0
|
2
Spring
2
Spring
|
@ -1 +1 @@
|
|||
Subproject commit 1c28f5c8e33c96d8389cda306442a8a25fc1e377
|
||||
Subproject commit 281dc597169d9934935d7aeed570434f63a3e358
|
|
@ -34,14 +34,14 @@ ENDPOINTS = {
|
|||
'Spring': 'http://localhost:9085',
|
||||
}
|
||||
|
||||
AVG_RUNS = 30
|
||||
AVG_RUNS = 5
|
||||
|
||||
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', 'POST', range(0, 30_000, 5000), (person_json, "application/json")),
|
||||
('/simulation/protobuf', 'POST', range(0, 30_000, 5000), (person_proto, "application/protobuf")),
|
||||
# ('/simulation/json', 'POST', range(0, 30_000, 5000), (person_json, "application/json")),
|
||||
('/image/save-big-image', 'POST', range(0, 500, 50), (open('big-image.png', 'rb').read(), "image/png")),
|
||||
('/static/small-image.png', 'GET', range(0, 30_000, 5000), None),
|
||||
('/static/big-image.png', 'GET', range(0, 500, 50), None),
|
||||
# ('/simulation/protobuf', 'POST', range(0, 30_000, 5000), (person_proto, "application/protobuf")),
|
||||
]
|
||||
|
|
|
@ -10,20 +10,19 @@ FRAMEWORKS = [f for f, _, _ in FRAMEWORKS]
|
|||
def setBoxColors(bp):
|
||||
for i, box in enumerate(bp['boxes']):
|
||||
box.set(color=FRAMEWORKS_COLORS[i])
|
||||
box.set(facecolor=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])
|
||||
for i, median in enumerate(bp['medians']):
|
||||
median.set(color='white')
|
||||
|
||||
|
||||
def plot_graph(x_data, y_data, title, x_label, y_label, filename, y_lim = None):
|
||||
print(filename)
|
||||
|
||||
old_x_data = x_data
|
||||
old_y_data = y_data
|
||||
|
||||
|
@ -40,20 +39,40 @@ def plot_graph(x_data, y_data, title, x_label, y_label, filename, y_lim = None):
|
|||
for f in range(len(FRAMEWORKS)):
|
||||
y_data[-1][f].append(old_y_data[f][i])
|
||||
|
||||
fig, axes = plt.subplots(ncols=len(x_data), sharey=True)
|
||||
fig = figure()
|
||||
ax = axes()
|
||||
|
||||
for ax, j in zip(axes, [i for i in range(len(x_data))]):
|
||||
bp = ax.boxplot(y_data[j], showfliers=False, patch_artist=True, positions=[i for i in range(len(FRAMEWORKS))])
|
||||
ax.set(xlabel=x_data[j], xticklabels=['' for _ in range(len(FRAMEWORKS))])
|
||||
ax.margins(0.05)
|
||||
all_positions = []
|
||||
|
||||
print(filename)
|
||||
# print(y_data)
|
||||
for j in range(len(x_data)):
|
||||
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)
|
||||
if j % 2 == 1:
|
||||
ax.set_facecolor('#f2f2f2')
|
||||
|
||||
# set title
|
||||
fig.suptitle(title)
|
||||
fig.supxlabel(x_label)
|
||||
fig.supylabel(y_label)
|
||||
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 = np.average(positions)
|
||||
avg_positions.append(avg)
|
||||
|
||||
ax.set_xticks(avg_positions)
|
||||
ax.set_xticklabels([str(x) for x in x_data])
|
||||
|
||||
plt.title(title)
|
||||
plt.xlabel(x_label)
|
||||
plt.ylabel(y_label)
|
||||
|
||||
if y_lim:
|
||||
plt.ylim(y_lim)
|
||||
|
@ -66,7 +85,6 @@ def plot_graph(x_data, y_data, title, x_label, y_label, filename, y_lim = None):
|
|||
plt.legend()
|
||||
|
||||
plt.tight_layout()
|
||||
fig.subplots_adjust(hspace=0, wspace=0)
|
||||
plt.savefig(f'{filename}.png')
|
||||
|
||||
plt.clf()
|
||||
|
|
|
@ -76,6 +76,8 @@ def run_tests(endpoint, method, num_requests, metadata):
|
|||
start_time = time.time()
|
||||
|
||||
futures = []
|
||||
#with requests.Session() as session:
|
||||
# futures = [executor.submit(send_request, session, url) for _ in range(num_request)]
|
||||
|
||||
half = floor(num_request/2)
|
||||
for i in range(num_request):
|
||||
|
@ -102,7 +104,7 @@ def run_tests(endpoint, method, num_requests, metadata):
|
|||
record(files[0], num_request, f"{num_request/elapsed_time:.2f}")
|
||||
record_resource(files[1], num_request, cpu, ram)
|
||||
|
||||
time.sleep(30)
|
||||
time.sleep(3)
|
||||
|
||||
def get_resource_usage():
|
||||
if CONTAINER_NAME == "": return 0, 0
|
||||
|
|
Loading…
Reference in New Issue