-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alexander Piskun <bigcat88@icloud.com>
- Loading branch information
Showing
15 changed files
with
309 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import sys | ||
|
||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from conf import NC_CFGS, init_nc, init_nc_app, init_nc_by_app_pass | ||
|
||
NC_VERSIONS = [] | ||
|
||
|
||
def measure_overhead(measure, title: str): | ||
penguin_means = { | ||
"Password": [], | ||
"AppPassword": [], | ||
"AppEcosystem": [], | ||
} | ||
|
||
for k, v in NC_CFGS.items(): | ||
NC_VERSIONS.append(init_nc_app(k, v).srv_version["string"]) | ||
|
||
for k, v in NC_CFGS.items(): | ||
nc = init_nc(k, v) | ||
if nc: | ||
result_nc, time_nc = measure(nc) | ||
penguin_means["Password"].append(time_nc) | ||
else: | ||
penguin_means["Password"].append(0) | ||
|
||
nc_ap = init_nc_by_app_pass(k, v) | ||
if nc_ap: | ||
result_nc_ap, time_nc_ap = measure(nc_ap) | ||
penguin_means["AppPassword"].append(time_nc_ap) | ||
else: | ||
penguin_means["AppPassword"].append(0) | ||
|
||
nc_ae = init_nc_app(k, v) | ||
result_nc_ae, time_nc_ae = measure(nc_ae) | ||
penguin_means["AppEcosystem"].append(time_nc_ae) | ||
|
||
# Uncomment only for functions that return predictable values. | ||
# if result_nc is not None: | ||
# assert result_nc == result_nc_ae | ||
# if result_nc_ap is not None: | ||
# assert result_nc_ap == result_nc_ae | ||
|
||
penguin_means = {k: v for k, v in penguin_means.items() if v} | ||
|
||
x = np.arange(len(NC_VERSIONS)) # the label locations | ||
width = 0.25 # the width of the bars | ||
multiplier = 0 | ||
|
||
fig, ax = plt.subplots(layout="constrained") | ||
|
||
for attribute, measurement in penguin_means.items(): | ||
offset = width * multiplier | ||
rects = ax.bar(x + offset, measurement, width, label=attribute) | ||
ax.bar_label(rects, padding=3) | ||
multiplier += 1 | ||
|
||
ax.set_ylabel("Time to execute") | ||
ax.set_title(title) | ||
ax.set_xticks(x + width, NC_VERSIONS) | ||
ax.legend(loc="upper left", ncols=3) | ||
values = [] | ||
for v in penguin_means.values(): | ||
values.append(max(v)) | ||
ax.set_ylim(0, max(values) + 0.18 * max(values)) | ||
|
||
|
||
def os_id(): | ||
if sys.platform.lower() == "darwin": | ||
return "macOS" | ||
elif sys.platform.lower() == "win32": | ||
return "Windows" | ||
return "Linux" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
from getpass import getuser | ||
from random import randbytes | ||
from time import perf_counter | ||
from typing import Any, Union | ||
|
||
import matplotlib.pyplot as plt | ||
from ae_overhead_common import measure_overhead, os_id | ||
from cpuinfo import get_cpu_info | ||
|
||
from nc_py_api import Nextcloud, NextcloudApp | ||
|
||
ITERS = 30 | ||
CACHE_SESS = False | ||
|
||
|
||
def measure_download_1mb(nc_obj: Union[Nextcloud, NextcloudApp]) -> [Any, float]: | ||
__result = None | ||
small_file_name = "1Mb.bin" | ||
small_file = randbytes(1024 * 1024) | ||
nc_obj.files.upload(small_file_name, small_file) | ||
start_time = perf_counter() | ||
for _ in range(ITERS): | ||
nc_obj.files.download(small_file_name) | ||
nc_obj._session.init_adapter(restart=not CACHE_SESS) # noqa | ||
end_time = perf_counter() | ||
nc_obj.files.delete(small_file_name, not_fail=True) | ||
return __result, round((end_time - start_time) / ITERS, 3) | ||
|
||
|
||
if __name__ == "__main__": | ||
title = f"download 1mb({ITERS} iters, CACHE={CACHE_SESS}) - {os_id()}, {get_cpu_info()['brand_raw']}" | ||
measure_overhead(measure_download_1mb, title) | ||
plt.savefig(f"results/dav_download_1mb__cache{int(CACHE_SESS)}_iters{ITERS}__{getuser()}.png", dpi=200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from getpass import getuser | ||
from io import BytesIO | ||
from random import randbytes | ||
from time import perf_counter | ||
from typing import Any, Union | ||
|
||
import matplotlib.pyplot as plt | ||
from ae_overhead_common import measure_overhead, os_id | ||
from cpuinfo import get_cpu_info | ||
|
||
from nc_py_api import Nextcloud, NextcloudApp | ||
|
||
ITERS = 10 | ||
CACHE_SESS = False | ||
|
||
|
||
def measure_download_100mb(nc_obj: Union[Nextcloud, NextcloudApp]) -> [Any, float]: | ||
__result = None | ||
medium_file_name = "100Mb.bin" | ||
medium_file = BytesIO() | ||
medium_file.write(randbytes(100 * 1024 * 1024)) | ||
medium_file.seek(0) | ||
nc_obj.files.upload_stream(medium_file_name, medium_file) | ||
start_time = perf_counter() | ||
for _ in range(ITERS): | ||
medium_file.seek(0) | ||
nc_obj.files.download2stream(medium_file_name, medium_file) | ||
nc_obj._session.init_adapter(restart=not CACHE_SESS) # noqa | ||
end_time = perf_counter() | ||
nc_obj.files.delete(medium_file_name, not_fail=True) | ||
return __result, round((end_time - start_time) / ITERS, 3) | ||
|
||
|
||
if __name__ == "__main__": | ||
title = f"download stream 100mb({ITERS} iters, CACHE={CACHE_SESS}) - {os_id()}, {get_cpu_info()['brand_raw']}" | ||
measure_overhead(measure_download_100mb, title) | ||
plt.savefig(f"results/dav_download_stream_100mb__cache{int(CACHE_SESS)}_iters{ITERS}__{getuser()}.png", dpi=200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from getpass import getuser | ||
from random import randbytes | ||
from time import perf_counter | ||
from typing import Any, Union | ||
|
||
import matplotlib.pyplot as plt | ||
from ae_overhead_common import measure_overhead, os_id | ||
from cpuinfo import get_cpu_info | ||
|
||
from nc_py_api import Nextcloud, NextcloudApp | ||
|
||
ITERS = 30 | ||
CACHE_SESS = False | ||
|
||
|
||
def measure_upload_1mb(nc_obj: Union[Nextcloud, NextcloudApp]) -> [Any, float]: | ||
__result = None | ||
small_file_name = "1Mb.bin" | ||
small_file = randbytes(1024 * 1024) | ||
start_time = perf_counter() | ||
for _ in range(ITERS): | ||
nc_obj.files.upload(small_file_name, small_file) | ||
nc_obj._session.init_adapter(restart=not CACHE_SESS) # noqa | ||
end_time = perf_counter() | ||
nc_obj.files.delete(small_file_name, not_fail=True) | ||
return __result, round((end_time - start_time) / ITERS, 3) | ||
|
||
|
||
if __name__ == "__main__": | ||
title = f"upload 1mb({ITERS} iters, CACHE={CACHE_SESS}) - {os_id()}, {get_cpu_info()['brand_raw']}" | ||
measure_overhead(measure_upload_1mb, title) | ||
plt.savefig(f"results/dav_upload_1mb__cache{int(CACHE_SESS)}_iters{ITERS}__{getuser()}.png", dpi=200) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from getpass import getuser | ||
from io import BytesIO | ||
from random import randbytes | ||
from time import perf_counter | ||
from typing import Any, Union | ||
|
||
import matplotlib.pyplot as plt | ||
from ae_overhead_common import measure_overhead, os_id | ||
from cpuinfo import get_cpu_info | ||
|
||
from nc_py_api import Nextcloud, NextcloudApp | ||
|
||
ITERS = 10 | ||
CACHE_SESS = False | ||
|
||
|
||
def measure_upload_100mb(nc_obj: Union[Nextcloud, NextcloudApp]) -> [Any, float]: | ||
__result = None | ||
medium_file_name = "100Mb.bin" | ||
medium_file = BytesIO() | ||
medium_file.write(randbytes(100 * 1024 * 1024)) | ||
start_time = perf_counter() | ||
for _ in range(ITERS): | ||
medium_file.seek(0) | ||
nc_obj.files.upload_stream(medium_file_name, medium_file) | ||
nc_obj._session.init_adapter(restart=not CACHE_SESS) # noqa | ||
end_time = perf_counter() | ||
nc_obj.files.delete(medium_file_name, not_fail=True) | ||
return __result, round((end_time - start_time) / ITERS, 3) | ||
|
||
|
||
if __name__ == "__main__": | ||
title = f"upload stream 100mb({ITERS} iters, CACHE={CACHE_SESS}) - {os_id()}, {get_cpu_info()['brand_raw']}" | ||
measure_overhead(measure_upload_100mb, title) | ||
plt.savefig(f"results/dav_upload_stream_100mb__cache{int(CACHE_SESS)}_iters{ITERS}__{getuser()}.png", dpi=200) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.