akashic-perflogger 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 ewigael
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: akashic-perflogger
3
+ Version: 0.1.2
4
+ Summary: Python performance logging library
5
+ Author-email: Akasha Mouginot <akasha.mouginot@protonmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ewigael/perflogger
8
+ Project-URL: Changelog, https://github.com/ewigael/perflogger/blob/main/docs/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/ewigael/perflogger/issues
10
+ Project-URL: Readme, https://github.com/ewigael/perflogger/blob/main/README.md
11
+ Keywords: performance,testing
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.14
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Dynamic: license-file
21
+
22
+ # perflogger
23
+
24
+ A performance tracking package for Python devs
25
+
26
+ ## Quick start
27
+
28
+ ##### Use pip
29
+
30
+ _Pypi package coming soon_
31
+
32
+ ##### Build from sources
33
+
34
+ ```bash
35
+ # Download sources
36
+ git clone https://github.com/ewigael/perflogger
37
+ # Move to sources directory
38
+ cd perflogger
39
+ # Install from sources with pip
40
+ pip install .
41
+ ```
42
+
43
+ ## Coming soon:
44
+
45
+ - ```PerfCounter``` class, to count how many times something happens
46
+ - Writing data to files
47
+ - ```PerfAnalyzer```, a co-project to vizualise and compare recorded data
@@ -0,0 +1,26 @@
1
+ # perflogger
2
+
3
+ A performance tracking package for Python devs
4
+
5
+ ## Quick start
6
+
7
+ ##### Use pip
8
+
9
+ _Pypi package coming soon_
10
+
11
+ ##### Build from sources
12
+
13
+ ```bash
14
+ # Download sources
15
+ git clone https://github.com/ewigael/perflogger
16
+ # Move to sources directory
17
+ cd perflogger
18
+ # Install from sources with pip
19
+ pip install .
20
+ ```
21
+
22
+ ## Coming soon:
23
+
24
+ - ```PerfCounter``` class, to count how many times something happens
25
+ - Writing data to files
26
+ - ```PerfAnalyzer```, a co-project to vizualise and compare recorded data
@@ -0,0 +1,34 @@
1
+ [project]
2
+ name = "akashic-perflogger"
3
+ version = "0.1.2"
4
+ description = "Python performance logging library"
5
+ authors = [
6
+ { name = "Akasha Mouginot", email = "akasha.mouginot@protonmail.com" }
7
+ ]
8
+ requires-python = ">=3.14"
9
+ readme = "README.md"
10
+ classifiers = [
11
+ "Development Status :: 3 - Alpha",
12
+ "Intended Audience :: Developers",
13
+
14
+ "Programming Language :: Python :: 3",
15
+ "Operating System :: OS Independent",
16
+
17
+ "Topic :: Software Development :: Libraries :: Python Modules",
18
+ ]
19
+ license = "MIT"
20
+ license-files = ["LICEN[CS]E*"]
21
+ keywords = ["performance", "testing"]
22
+
23
+ [project.urls]
24
+ Homepage = "https://github.com/ewigael/perflogger"
25
+ Changelog = "https://github.com/ewigael/perflogger/blob/main/docs/CHANGELOG.md"
26
+ Issues = "https://github.com/ewigael/perflogger/issues"
27
+ Readme = " https://github.com/ewigael/perflogger/blob/main/README.md"
28
+
29
+ [build-system]
30
+ requires = ["setuptools>=80"]
31
+ build-backend = "setuptools.build_meta"
32
+
33
+ [tool.setuptools.packages.find]
34
+ where = ["src"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,47 @@
1
+ Metadata-Version: 2.4
2
+ Name: akashic-perflogger
3
+ Version: 0.1.2
4
+ Summary: Python performance logging library
5
+ Author-email: Akasha Mouginot <akasha.mouginot@protonmail.com>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/ewigael/perflogger
8
+ Project-URL: Changelog, https://github.com/ewigael/perflogger/blob/main/docs/CHANGELOG.md
9
+ Project-URL: Issues, https://github.com/ewigael/perflogger/issues
10
+ Project-URL: Readme, https://github.com/ewigael/perflogger/blob/main/README.md
11
+ Keywords: performance,testing
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Intended Audience :: Developers
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Operating System :: OS Independent
16
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
17
+ Requires-Python: >=3.14
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Dynamic: license-file
21
+
22
+ # perflogger
23
+
24
+ A performance tracking package for Python devs
25
+
26
+ ## Quick start
27
+
28
+ ##### Use pip
29
+
30
+ _Pypi package coming soon_
31
+
32
+ ##### Build from sources
33
+
34
+ ```bash
35
+ # Download sources
36
+ git clone https://github.com/ewigael/perflogger
37
+ # Move to sources directory
38
+ cd perflogger
39
+ # Install from sources with pip
40
+ pip install .
41
+ ```
42
+
43
+ ## Coming soon:
44
+
45
+ - ```PerfCounter``` class, to count how many times something happens
46
+ - Writing data to files
47
+ - ```PerfAnalyzer```, a co-project to vizualise and compare recorded data
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/akashic_perflogger.egg-info/PKG-INFO
5
+ src/akashic_perflogger.egg-info/SOURCES.txt
6
+ src/akashic_perflogger.egg-info/dependency_links.txt
7
+ src/akashic_perflogger.egg-info/top_level.txt
8
+ src/perflogger/__init__.py
9
+ src/perflogger/perflogger.py
@@ -0,0 +1,24 @@
1
+ from importlib.metadata import metadata
2
+
3
+ _metadata = metadata("perflogger")
4
+
5
+ __package_name__ = _metadata["Name"]
6
+ __version__ = _metadata["Version"]
7
+ __authors__ = _metadata.get_all("Author-email")
8
+ __description__ = _metadata.get("Summary", "")
9
+
10
+ __urls__ = dict(item.split(", ") for item in _metadata.get_all("Project-URL"))
11
+
12
+
13
+ def print_metadata():
14
+ print(
15
+ f"{__project_name__} {__version__}\n"
16
+ f"{__description__}\n"
17
+ f"Authored by: {__authors__}\n"
18
+ f"Repository: {__urls__["Repository"]}\n"
19
+ f"Changelog: {__urls__["Changelog"]}\n"
20
+ f"Issues: {__urls__["Issues"]}",
21
+ )
22
+
23
+
24
+ from .perflogger import PerfLogger
@@ -0,0 +1,125 @@
1
+ import inspect
2
+ import time
3
+ import weakref
4
+
5
+
6
+ class PerfLogger:
7
+
8
+ _instances = []
9
+
10
+ def __init__(self, name=None, tick_func=time.perf_counter, avgs_step=1):
11
+
12
+ PerfLogger._instances.append(weakref.ref(self))
13
+
14
+ self.name = (
15
+ name if name is not None else inspect.currentframe().f_back.f_code.co_name
16
+ )
17
+ self.tick = tick_func
18
+ self.avgs_step = avgs_step
19
+
20
+ self.tags = []
21
+ self.tags_data = {}
22
+ self.avgs = {}
23
+ self._avgs_counter = None
24
+
25
+ @classmethod
26
+ def get_all_instances(cls):
27
+ """Return a list of all instances of current class in creation order"""
28
+ cls._instances[:] = [ref for ref in cls._instances if ref() is not None]
29
+ return [ref() for ref in cls._instances]
30
+
31
+ def start(self):
32
+ """Clear the tags table and init a start tag"""
33
+ self.clear()
34
+ self.tags = [("start", self.tick())]
35
+
36
+ def clear(self):
37
+ """Clear the tags table"""
38
+ self.tags.clear()
39
+
40
+ def add(self, tag_name):
41
+ """Add a new tag in the tags table as the delta between now and last tag;
42
+ append that delta to the tags_data table to later compute averages"""
43
+ now = self.tick()
44
+ self.tags_data.setdefault(tag_name, []).append(now - self.tags[-1][1])
45
+ self.tags.append((tag_name, now))
46
+
47
+ def _set_averages(self):
48
+ """Compute averages from stored data"""
49
+ self.avgs.clear()
50
+ for name, data in self.tags_data.items():
51
+ self.avgs[name] = sum(data) / len(data)
52
+
53
+ def get_deltas(self):
54
+ """Return deltas stored in the tags table both in a human readable format and true float"""
55
+
56
+ # Black/PEP8 does us dirty here so here's the same code in a more leggible format
57
+ # return [
58
+ # (
59
+ # name,
60
+ # f"{vs[-1]:.2f}s" if vs[-1] >= 1
61
+ # else f"{vs[-1] * 1e3:.2f}ms" if vs[-1] >= 1e-3
62
+ # else f"{vs[-1] * 1e6:.2f}μs" if vs[-1] >= 1e-6
63
+ # else f"{vs[-1] * 1e9:.2f}ns",
64
+ # vs[-1]
65
+ # ) for name, vs in self.tags_data.items()
66
+ # ]
67
+
68
+ return [
69
+ (
70
+ name,
71
+ (
72
+ f"{vs[-1]:.2f}s"
73
+ if vs[-1] >= 1
74
+ else (
75
+ f"{vs[-1] * 1e3:.2f}ms"
76
+ if vs[-1] >= 1e-3
77
+ else (
78
+ f"{vs[-1] * 1e6:.2f}μs"
79
+ if vs[-1] >= 1e-6
80
+ else f"{vs[-1] * 1e9:.2f}ns"
81
+ )
82
+ )
83
+ ),
84
+ vs[-1],
85
+ )
86
+ for name, vs in self.tags_data.items()
87
+ ]
88
+
89
+ def get_averages(self):
90
+ if self._avgs_counter is None:
91
+ self._avgs_counter = self.tick()
92
+
93
+ if self.tick() - self._avgs_counter >= self.avgs_step:
94
+ self._set_averages()
95
+ self.tags_data.clear()
96
+ self._avgs_counter = self.tick()
97
+
98
+ # Black/PEP8 does us dirty here so here's the same return value in more legible code
99
+ # return [
100
+ # (
101
+ # name,
102
+ # f"{vs:.2f}s" if vs >= 1
103
+ # else f"{vs * 1e3:.2f}ms" if vs >= 1e-3
104
+ # else f"{vs * 1e6:.2f}μs" if vs >= 1e-6
105
+ # else f"{vs * 1e9:.2f}ns",
106
+ # vs
107
+ # ) for name, vs in self.avgs.items()
108
+ # ]
109
+
110
+ return [
111
+ (
112
+ name,
113
+ (
114
+ f"{vs:.2f}s"
115
+ if vs >= 1
116
+ else (
117
+ f"{vs * 1e3:.2f}ms"
118
+ if vs >= 1e-3
119
+ else f"{vs * 1e6:.2f}μs" if vs >= 1e-6 else f"{vs * 1e9:.2f}ns"
120
+ )
121
+ ),
122
+ vs,
123
+ )
124
+ for name, vs in self.avgs.items()
125
+ ]