File: aa_overhead_ocs.py

package info (click to toggle)
nc-py-api 0.19.2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,320 kB
  • sloc: python: 12,415; makefile: 238; xml: 100; javascript: 56; sh: 14
file content (27 lines) | stat: -rw-r--r-- 878 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
from getpass import getuser
from time import perf_counter
from typing import Any

import matplotlib.pyplot as plt
from aa_overhead_common import measure_overhead, os_id

from nc_py_api import Nextcloud, NextcloudApp

ITERS = 100
CACHE_SESS = False


def measure_get_details(nc_obj: Nextcloud | NextcloudApp) -> [Any, float]:
    __result = None
    start_time = perf_counter()
    for _ in range(ITERS):
        __result = nc_obj.users.get_details()
        nc_obj._session.init_adapter(restart=not CACHE_SESS)  # noqa
    end_time = perf_counter()
    return __result, round((end_time - start_time) / ITERS, 3)


if __name__ == "__main__":
    title = f"OCS: get_user, {ITERS} iters, CACHE={CACHE_SESS} - {os_id()}"
    measure_overhead(measure_get_details, title)
    plt.savefig(f"results/ocs_user_get_details__cache{int(CACHE_SESS)}_iters{ITERS}__{getuser()}.png", dpi=200)