-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathpbe
More file actions
executable file
·56 lines (50 loc) · 2.22 KB
/
pbe
File metadata and controls
executable file
·56 lines (50 loc) · 2.22 KB
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
#
# -*- coding: utf-8 -*-
# vim: ts=4 sw=4 tw=100 et ai si
#
# Copyright (C) 2019-2025 Intel Corporation
# SPDX-License-Identifier: BSD-3-Clause
#
# Author: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
"""
pbe - a tool for measuring C-states power break even.
"""
import sys
from pathlib import Path
_prjroot = Path(__file__).parent
# This script can be run in two ways:
# 1. From a source tree - the script resides in the project root alongside the 'wulttools'
# directory. The 'pepc' and 'stats-collect' projects are expected to be checked out next to
# the project root.
# 2. From an installation - the script is installed (e.g., under '/usr/bin'), and
# 'wulttools', 'statscollecttools', and 'pepclibs' are installed as regular Python packages.
#
# In case 1, we need to add the project root and the 'pepc' and 'stats-collect' project
# directories to 'sys.path' before importing anything, so that Python resolves 'wulttools',
# 'statscollecttools', and 'pepclibs' from the source tree. This must be done upfront - before
# any import - to prevent Python from finding and partially importing a system-installed version
# first, and then mixing it with the source version.
if (_prjroot / "wulttools").is_dir():
_pepcroot = _prjroot.parent / "pepc"
if not _pepcroot.is_dir():
print(f"Error: 'wulttools' source found at '{_prjroot}' but the 'pepc' project "
f"directory was not found at '{_pepcroot}'", file=sys.stderr)
raise SystemExit(1)
_stcroot = _prjroot.parent / "stats-collect"
if not _stcroot.is_dir():
print(f"Error: 'wulttools' source found at '{_prjroot}' but the 'stats-collect' project "
f"directory was not found at '{_stcroot}'", file=sys.stderr)
raise SystemExit(1)
sys.path.insert(0, str(_stcroot))
sys.path.insert(0, str(_pepcroot))
sys.path.insert(0, str(_prjroot))
try:
from wulttools.pbe._Pbe import main
except ImportError as err:
print(f"Error: Cannot import 'wulttools': {err}", file=sys.stderr)
print("Make sure 'wulttools' is installed, or run the script from its source tree",
file=sys.stderr)
raise SystemExit(1) from None
if __name__ == "__main__":
raise SystemExit(main())