File: benchmark_proc_get_all.py

package info (click to toggle)
px 3.6.9-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 5,172 kB
  • sloc: python: 6,445; sh: 205; makefile: 4
file content (33 lines) | stat: -rwxr-xr-x 536 bytes parent folder | download | duplicates (2)
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
28
29
30
31
32
33
#!/usr/bin/env python3

"""Benchmark listing all processes

Usage:
  benchmark_proc_get_all.py
"""

import os
import sys
import time


MYDIR = os.path.dirname(os.path.abspath(__file__))
sys.path.insert(0, os.path.join(MYDIR, ".."))

from px import px_process  # noqa: E402

LAPS = 20


def main():
    t0 = time.time()
    for _ in range(LAPS):
        px_process.get_all()
    t1 = time.time()
    dt_seconds = t1 - t0

    print(f"Getting all processes takes {1000 * dt_seconds / LAPS:.0f}ms")


if __name__ == "__main__":
    main()