1
0
forked from ScoDoc/ScoDoc

update bench

This commit is contained in:
Emmanuel Viennet 2022-04-01 16:08:59 +02:00
parent 482c2a24ec
commit eaa7c64e41
2 changed files with 9 additions and 2 deletions

1
tests/bench/__init__.py Normal file
View File

@ -0,0 +1 @@
# Simple benchmarks

View File

@ -5,6 +5,7 @@ import time
from flask import g from flask import g
from flask_login import login_user from flask_login import login_user
from app.models import FormSemestre
from config import RunningConfig as BenchConfig from config import RunningConfig as BenchConfig
import app import app
@ -12,10 +13,13 @@ from app import db, create_app
from app import clear_scodoc_cache from app import clear_scodoc_cache
from app.auth.models import get_super_admin from app.auth.models import get_super_admin
from app.scodoc import notesdb as ndb from app.scodoc import notesdb as ndb
from app.scodoc import notes_table
from app.comp.res_compat import NotesTableCompat
from app.comp import res_sem
def setup_generator(dept: str): def setup_generator(dept: str):
"setup app"
# Setup # Setup
apptest = create_app(BenchConfig) apptest = create_app(BenchConfig)
# Run tests: # Run tests:
@ -39,12 +43,14 @@ def setup_generator(dept: str):
def bench_notes_table(dept: str, formsemestre_ids: list[int]) -> float: def bench_notes_table(dept: str, formsemestre_ids: list[int]) -> float:
"benchmark note stable"
for client in setup_generator(dept): for client in setup_generator(dept):
tot_time = 0.0 tot_time = 0.0
for formsemestre_id in formsemestre_ids: for formsemestre_id in formsemestre_ids:
print(f"building sem {formsemestre_id}...") print(f"building sem {formsemestre_id}...")
formsemestre = FormSemestre.query.get(formsemestre_id)
t0 = time.time() t0 = time.time()
nt = notes_table.NotesTable(formsemestre_id) nt: NotesTableCompat = res_sem.load_formsemestre_results(formsemestre)
tot_time += time.time() - t0 tot_time += time.time() - t0
print(f"Total time: {tot_time}") print(f"Total time: {tot_time}")
return tot_time return tot_time