kenenet 0.9.1__py3-none-any.whl → 0.9.2__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 +30 -28
- {kenenet-0.9.1.dist-info → kenenet-0.9.2.dist-info}/METADATA +1 -1
- kenenet-0.9.2.dist-info/RECORD +5 -0
- kenenet-0.9.1.dist-info/RECORD +0 -5
- {kenenet-0.9.1.dist-info → kenenet-0.9.2.dist-info}/WHEEL +0 -0
- {kenenet-0.9.1.dist-info → kenenet-0.9.2.dist-info}/top_level.txt +0 -0
kenenet/__init__.py
CHANGED
@@ -287,9 +287,9 @@ _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
|
+
_ignore_line = {'frame = inspect.currentframe().f_back', 'filename = frame.f_code.co_filename', 'if _current_context is None:', 'sys.settrace(None)', 'currentframe'}
|
291
291
|
|
292
|
-
def time_code(label=None):
|
292
|
+
def time_code(details=True, chunks=True, label=None):
|
293
293
|
global _current_context, _timings, _line_start_time, _block_timings, _stack, _ignore_line
|
294
294
|
|
295
295
|
# Get the frame of the caller
|
@@ -356,31 +356,32 @@ def time_code(label=None):
|
|
356
356
|
sys.settrace(trace_function)
|
357
357
|
|
358
358
|
else:
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
|
372
|
-
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
359
|
+
if details:
|
360
|
+
sys.settrace(None)
|
361
|
+
context = _current_context
|
362
|
+
_current_context = None
|
363
|
+
_line_start_time = None
|
364
|
+
|
365
|
+
if not _timings[context]:
|
366
|
+
quick_print(f"No times recorded: {context}")
|
367
|
+
return
|
368
|
+
|
369
|
+
sorted_timings = sorted(_timings[context], key=lambda x: x[2], reverse=True)
|
370
|
+
|
371
|
+
quick_print(f"\nTime spent on each line: {context}")
|
372
|
+
quick_print("-" * 80)
|
373
|
+
quick_print(f"{'Line':>6} | {'Time':>12} | Code")
|
374
|
+
quick_print("-" * 80)
|
375
|
+
|
376
|
+
for lineno, line_content, elapsed in sorted_timings:
|
377
|
+
if line_content not in _ignore_line:
|
378
|
+
quick_print(f"{lineno:6d} | {elapsed:12.6f} | {line_content}")
|
379
|
+
|
380
|
+
quick_print("-" * 80)
|
381
|
+
total_time = sum(elapsed for _, _, elapsed in _timings[context])
|
382
|
+
quick_print(f"Total execution time: {total_time:.6f}")
|
382
383
|
|
383
|
-
if _block_timings:
|
384
|
+
if _block_timings and chunks:
|
384
385
|
quick_print("\nTime spent on chunks of code:")
|
385
386
|
quick_print("-" * 80)
|
386
387
|
quick_print(f"{'Chunks':^40} | {'Time':>12} | {'% of Time Spent':>10}")
|
@@ -390,8 +391,9 @@ def time_code(label=None):
|
|
390
391
|
sorted_blocks = sorted(_block_timings.items(), key=lambda x: x[1], reverse=True)
|
391
392
|
|
392
393
|
for block, elapsed in sorted_blocks:
|
393
|
-
|
394
|
-
|
394
|
+
if block not in _ignore_line:
|
395
|
+
percentage = (elapsed / total_time) * 100 if total_time > 0 else 0
|
396
|
+
quick_print(f"{block[:40]:40} | {elapsed:12.6f} | {percentage:10.2f}%")
|
395
397
|
|
396
398
|
quick_print("-" * 80)
|
397
399
|
|
@@ -0,0 +1,5 @@
|
|
1
|
+
kenenet/__init__.py,sha256=OSA1tIx7og8oxbvVqp15kgqrda-yNy7qPb4ry8K7998,16571
|
2
|
+
kenenet-0.9.2.dist-info/METADATA,sha256=grsmoIIL7TyubyTHBQ_QG7HxMfIJPj0u5MmobDZdk1I,633
|
3
|
+
kenenet-0.9.2.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
+
kenenet-0.9.2.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
+
kenenet-0.9.2.dist-info/RECORD,,
|
kenenet-0.9.1.dist-info/RECORD
DELETED
@@ -1,5 +0,0 @@
|
|
1
|
-
kenenet/__init__.py,sha256=CKY529xoL2OuIzn_LmIDmgPUoVJb8pnNzI7oYUn2Zdg,16349
|
2
|
-
kenenet-0.9.1.dist-info/METADATA,sha256=dEhWYGEm7TMgXZTQwENMH7fGSljm3OfaduW5lV-9jV0,633
|
3
|
-
kenenet-0.9.1.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
|
4
|
-
kenenet-0.9.1.dist-info/top_level.txt,sha256=gUsWXLrM0jF4b4nbYJZdksdFewIx_F3xOF-zER8fMuQ,8
|
5
|
-
kenenet-0.9.1.dist-info/RECORD,,
|
File without changes
|
File without changes
|