Skip to content
Snippets Groups Projects
Commit e9262853 authored by Henrik tom Wörden's avatar Henrik tom Wörden
Browse files

TST: write output to file

parent 655d9468
No related branches found
No related tags found
1 merge request!9F perf test
Pipeline #59709 passed with warnings
"""
Tests CPU and Memory usage of RuQaD
"""
import cProfile, pstats, io
from pstats import SortKey
from time import sleep,time
from tempfile import TemporaryDirectory
import cProfile
import io
import os
import pstats
import shutil
from datetime import datetime, timezone
from pathlib import Path
from pstats import SortKey
from tempfile import TemporaryDirectory
from time import sleep, time
from memory_profiler import memory_usage
from memory_profiler import profile as mprofile
from ruqad.qualitycheck import QualityChecker
from ruqad.kadi import collect_records_created_after, download_eln_for, KadiManager
from ruqad.crawler import trigger_crawler
import os
import shutil
from memory_profiler import memory_usage
from ruqad.kadi import KadiManager, collect_records_created_after, download_eln_for
from ruqad.qualitycheck import QualityChecker
SKIP_QUALITY_CHECK = os.getenv("SKIP_QUALITY_CHECK") is not None
KADIARGS = {
......@@ -69,14 +70,12 @@ def test_cpu():
pr.enable()
_run(n=1)
pr.disable()
s = io.StringIO()
with open("performance.txt", 'a') as s:
sortby = SortKey.CUMULATIVE
ps = pstats.Stats(pr, stream=s).sort_stats(sortby)
ps.print_stats(10)
print(s.getvalue())
ps.print_stats("ruqad", 10)
ps.print_stats("crawler", 10)
print(s.getvalue())
def test_runtime_eln_download():
cut_off_date = datetime.fromisoformat("1990-01-01 02:34:42.484312+00:00")
......@@ -91,7 +90,8 @@ def test_runtime_eln_download():
download_eln_for(manager, rec_ids[0], path=eln_file)
stop = time()
print(f"time for downloading eln: {stop-start:.2f} s")
with open("performance.txt", 'a') as s:
s.write(f"time for downloading eln: {stop-start:.2f} s")
def test_runtime_crawler():
cut_off_date = datetime.fromisoformat("1990-01-01 02:34:42.484312+00:00")
......@@ -112,7 +112,8 @@ def test_runtime_crawler():
trigger_crawler(target_dir=cdir)
stop = time()
print(f"time for crawling eln: {stop-start:.2f} s")
with open("performance.txt", 'a') as s:
s.write(f"time for crawling eln: {stop-start:.2f} s")
if __name__ == "__main__":
test_memory()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment