Skip to content

Commit 255d570

Browse files
committed
update readme and example
1 parent 3227f93 commit 255d570

2 files changed

Lines changed: 21 additions & 4 deletions

File tree

README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ stats.norm(loc=1, scale=0.02).pdf(1)
4444
# Retrieve statistics for wrapped functions
4545
print("Call counts:", stats.norm.pdf._get_counts())
4646
print("Parameter stats:", stats.norm.pdf._get_param_stats())
47+
print("Timing stats:", stats.norm.pdf._get_timing())
4748
```
4849

4950
The `_get_counts()` method returns a tuple of:
@@ -59,6 +60,16 @@ The `_get_param_stats()` method returns detailed statistics for each parameter:
5960
- Tracked parameter values (if specified)
6061
- Counts for each tracked value (if specified)
6162

63+
The `_get_timing()` method returns a dictionary with timing statistics:
64+
65+
- `'total'`: Total time spent in all calls (seconds)
66+
- `'average'`: Average time per call (seconds)
67+
- `'min'`: Minimum time for a single call (seconds)
68+
- `'max'`: Maximum time for a single call (seconds)
69+
70+
Timing measurements use `time.perf_counter()` for high-resolution timing with
71+
nanosecond-level accuracy on most platforms.
72+
6273
### Manual Function Decoration
6374

6475
For more control, use the `stats_deco_auto` decorator to automatically track all
@@ -79,6 +90,7 @@ my_function(5, 20, "custom")
7990

8091
print(my_function._get_counts())
8192
print(my_function._get_param_stats())
93+
print(my_function._get_timing())
8294
```
8395

8496
For fine-grained control over which parameter values to track, use `stats_deco`:
@@ -107,8 +119,17 @@ from telemetric.statswrapper import print_all_stats
107119

108120
# After your code has run
109121
print_all_stats()
122+
123+
# Control timing precision with scientific notation (default: 6 digits)
124+
print_all_stats(timing_digits=3) # Display timing with 3 decimal places
125+
126+
# Or disable rounding for full precision
127+
print_all_stats(timing_digits=None)
110128
```
111129

130+
The output includes call counts, parameter usage, and timing statistics in
131+
scientific notation for each wrapped function.
132+
112133
### OpenTelemetry Integration (Legacy)
113134

114135
The library also supports OpenTelemetry-based tracing for distributed systems:

examples/test_scipy.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@
44
from telemetric import install
55
from telemetric.statswrapper import print_all_stats
66

7-
# from telemetric.console import setup_console
8-
97
install(["scipy.stats._correlation", "scipy.stats._distn_infrastructure"])
10-
# initialize()
11-
# setup_console()
128

139
from scipy import stats # noqa: E402
1410

0 commit comments

Comments
 (0)