Skip to content

Commit 93be090

Browse files
CopilotBorda
andcommitted
Refactor metrics example to use single formatted print statement
- Replace multiple trivial print calls with one aggregated formatted f-string (comment 2744970314) - Improves code conciseness and readability - All tests passing (14/14) Co-authored-by: Borda <6035284+Borda@users.noreply.github.com>
1 parent 1edaf30 commit 93be090

1 file changed

Lines changed: 14 additions & 12 deletions

File tree

examples/metrics_example.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,20 @@ def comprehensive_operation(x):
152152
comprehensive_operation(2000) # Size limit rejection
153153

154154
stats = comprehensive_operation.metrics.get_stats()
155-
print("\nComplete metrics snapshot:")
156-
print(f" Hits: {stats.hits}")
157-
print(f" Misses: {stats.misses}")
158-
print(f" Hit rate: {stats.hit_rate:.1f}%")
159-
print(f" Total calls: {stats.total_calls}")
160-
print(f" Avg latency: {stats.avg_latency_ms:.2f}ms")
161-
print(f" Stale hits: {stats.stale_hits}")
162-
print(f" Recalculations: {stats.recalculations}")
163-
print(f" Wait timeouts: {stats.wait_timeouts}")
164-
print(f" Size limit rejections: {stats.size_limit_rejections}")
165-
print(f" Entry count: {stats.entry_count}")
166-
print(f" Total size (bytes): {stats.total_size_bytes}")
155+
print(
156+
f"\nComplete metrics snapshot:\n"
157+
f" Hits: {stats.hits}\n"
158+
f" Misses: {stats.misses}\n"
159+
f" Hit rate: {stats.hit_rate:.1f}%\n"
160+
f" Total calls: {stats.total_calls}\n"
161+
f" Avg latency: {stats.avg_latency_ms:.2f}ms\n"
162+
f" Stale hits: {stats.stale_hits}\n"
163+
f" Recalculations: {stats.recalculations}\n"
164+
f" Wait timeouts: {stats.wait_timeouts}\n"
165+
f" Size limit rejections: {stats.size_limit_rejections}\n"
166+
f" Entry count: {stats.entry_count}\n"
167+
f" Total size (bytes): {stats.total_size_bytes}"
168+
)
167169

168170
# Example 5: Programmatic access for monitoring
169171
print("\n" + "=" * 60)

0 commit comments

Comments
 (0)