mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-01 05:20:32 +08:00
Printing profile on sig kill. (#44)
* added skeleton for terminal logger * done skeleton terminal writer logic... todo: actual calls to the write classes * moved lambda to top function * added logic to support timing * prettier printing * prettier printing * lint * separated out timing and other stats variables. printing in dict format * keeping logging history and wiping rest * updated logic to calculate total times instead of average times * made stats tracker configurable * moved stats tracker and profiler to own class file; implemented basic functionality for profiler * lint removing duplicate function * update readme; moved around config variables * profiler prints on sig kill
This commit is contained in:
1 parent
47691eb291
commit
86b1011ae1
8 files changed
+46
-24
No files matched your search
@@ -59,7 +59,7 @@ def check_print_stats_step(func: Callable) -> Callable:
|
||||
def wrapper(self, *args, **kwargs):
|
||||
ret = None
|
||||
if (
|
||||
self.step % self.config.steps_per_log == 0
|
||||
self.step % self.config.logging_configs.steps_per_log == 0
|
||||
or (self.config.steps_per_save and self.step % self.config.steps_per_save == 0)
|
||||
or self.step % self.config.steps_per_test == 0
|
||||
):
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
"""
|
||||
Profiler base class and functionality
|
||||
"""
|
||||
import sys
|
||||
import logging
|
||||
import sys
|
||||
import time
|
||||
from typing import Callable
|
||||
|
||||
@@ -19,18 +19,19 @@ def time_function(func: Callable) -> Callable:
|
||||
def wrapper(*args, **kwargs):
|
||||
start = time.time()
|
||||
ret = func(*args, **kwargs)
|
||||
vals = vars(sys.modules[func.__module__])
|
||||
class_str = ""
|
||||
for attr in func.__qualname__.split(".")[:-1]:
|
||||
class_str += f"{vals[attr].__qualname__}_"
|
||||
class_str += func.__name__
|
||||
PROFILER.update_time(class_str, start, time.time())
|
||||
if PROFILER:
|
||||
vals = vars(sys.modules[func.__module__])
|
||||
class_str = ""
|
||||
for attr in func.__qualname__.split(".")[:-1]:
|
||||
class_str += f"{vals[attr].__qualname__}_"
|
||||
class_str += func.__name__
|
||||
PROFILER.update_time(class_str, start, time.time())
|
||||
return ret
|
||||
|
||||
return wrapper
|
||||
|
||||
|
||||
@decorate_all([check_main_thread, check_profiler_enabled])
|
||||
@decorate_all([check_profiler_enabled, check_main_thread])
|
||||
class Profiler:
|
||||
"""Profiler class"""
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class Stats(enum.Enum):
|
||||
ETA = "ETA (time)"
|
||||
|
||||
|
||||
@decorate_all([check_main_thread, check_stats_enabled])
|
||||
@decorate_all([check_stats_enabled, check_main_thread])
|
||||
class StatsTracker:
|
||||
"""Stats Tracker class"""
|
||||
|
||||
|
||||
Reference in new issue
Block a user