kenenet 0.8.8__py3-none-any.whl → 0.9.0__py3-none-any.whl
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.
- kenenet/__init__.py +29 -19
- {kenenet-0.8.8.dist-info → kenenet-0.9.0.dist-info}/METADATA +1 -1
- kenenet-0.9.0.dist-info/RECORD +5 -0
- kenenet-0.8.8.dist-info/RECORD +0 -5
- {kenenet-0.8.8.dist-info → kenenet-0.9.0.dist-info}/WHEEL +0 -0
- {kenenet-0.8.8.dist-info → kenenet-0.9.0.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -287,10 +287,11 @@ _block_timings = defaultdict(float)
|
|
287
287
|
_current_context = None
|
288
288
|
_line_start_time = None
|
289
289
|
_stack = []
|
290
|
+
_ignore_line = {'frame = inspect.currentframe().f_back', 'filename = frame.f_code.co_filename', 'if _current_context is None:', 'sys.settrace(None)'}
|
290
291
|
|
291
292
|
|
292
|
-
def time_code(label=None):
|
293
|
-
global _current_context, _timings, _line_start_time, _block_timings, _stack
|
293
|
+
def time_code(print_details=True, print_chunks=True, label=None):
|
294
|
+
global _current_context, _timings, _line_start_time, _block_timings, _stack, _ignore_line
|
294
295
|
|
295
296
|
# Get the frame of the caller
|
296
297
|
frame = inspect.currentframe().f_back
|
@@ -299,7 +300,7 @@ def time_code(label=None):
|
|
299
300
|
if _current_context is None:
|
300
301
|
# First call - start timing
|
301
302
|
_current_context = label or f"timing_{len(_timings)}"
|
302
|
-
quick_print(f"
|
303
|
+
quick_print(f"Starting timer: {_current_context}")
|
303
304
|
_line_start_time = time.time()
|
304
305
|
_block_timings.clear()
|
305
306
|
_stack = []
|
@@ -362,27 +363,36 @@ def time_code(label=None):
|
|
362
363
|
_line_start_time = None
|
363
364
|
|
364
365
|
if not _timings[context]:
|
365
|
-
quick_print(f"No
|
366
|
+
quick_print(f"No times recorded: {context}")
|
366
367
|
return
|
367
368
|
|
368
|
-
|
369
|
-
|
370
|
-
quick_print(f"\n⏱️ Detailed timing results for context: {context}")
|
371
|
-
quick_print("-" * 80)
|
372
|
-
quick_print(f"{'Line':>6} | {'Time':>12} | Code")
|
373
|
-
quick_print("-" * 80)
|
374
|
-
|
375
|
-
for lineno, line_content, elapsed in sorted_timings:
|
376
|
-
quick_print(f"{lineno:6d} | {elapsed:12.6f} | {line_content}")
|
377
|
-
|
378
|
-
quick_print("-" * 80)
|
369
|
+
# Calculate total time regardless of printing options
|
379
370
|
total_time = sum(elapsed for _, _, elapsed in _timings[context])
|
380
|
-
quick_print(f"Total execution time: {total_time * 1000:.6f} ms")
|
381
371
|
|
382
|
-
if
|
383
|
-
|
372
|
+
# Print detailed line-by-line timings if requested
|
373
|
+
if print_details:
|
374
|
+
sorted_timings = sorted(_timings[context], key=lambda x: x[2], reverse=True)
|
375
|
+
|
376
|
+
quick_print(f"\nTime spent on each line: {context}")
|
377
|
+
quick_print("-" * 80)
|
378
|
+
quick_print(f"{'Line':>6} | {'Time':>12} | Code")
|
379
|
+
quick_print("-" * 80)
|
380
|
+
|
381
|
+
for lineno, line_content, elapsed in sorted_timings:
|
382
|
+
if line_content not in _ignore_line:
|
383
|
+
quick_print(f"{lineno:6d} | {elapsed:12.6f} | {line_content}")
|
384
|
+
|
385
|
+
quick_print("-" * 80)
|
386
|
+
quick_print(f"Total execution time: {total_time:.6f}")
|
387
|
+
else:
|
388
|
+
# Just print the total time if detailed printing is disabled
|
389
|
+
quick_print(f"\nTotal execution time for {context}: {total_time:.6f}")
|
390
|
+
|
391
|
+
# Print chunk summaries if requested
|
392
|
+
if print_chunks and _block_timings:
|
393
|
+
quick_print("\nTime spent on chunks of code:")
|
384
394
|
quick_print("-" * 80)
|
385
|
-
quick_print(f"{'
|
395
|
+
quick_print(f"{'Chunks':^40} | {'Time':>12} | {'% of Time Spent':>10}")
|
386
396
|
quick_print("-" * 80)
|
387
397
|
|
388
398
|
# Sort block timings by time
|
@@ -0,0 +1,5 @@
|
|
1
|
+
kenenet/__init__.py,sha256=Yaq9XqVDXyqqOzPjaEw9DVGTc5aJXOhatRThGrGB7b8,16838
|
2
|
+
kenenet-0.9.0.dist-info/METADATA,sha256=73MKfyK4U4u7HCd76ZUHzkjXvt2YHxUKRM4BdJ43hbI,633
|
3
|
+
kenenet-0.9.0.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
+
kenenet-0.9.0.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
+
kenenet-0.9.0.dist-info/RECORD,,
|
kenenet-0.8.8.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=Zv3A0UQ3NsHqM7OxO0cII3NHmlUvzhArwKxuX2Ch4Nk,16220
|
2
|
-
kenenet-0.8.8.dist-info/METADATA,sha256=tHUmAN5bqgsw9FMtMs9u-1ehqHoTg8ekwBmexpfp_9A,633
|
3
|
-
kenenet-0.8.8.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
-
kenenet-0.8.8.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-0.8.8.dist-info/RECORD,,
|
File without changes
|
File without changes
|