clan_vm_manager: Add CUMTIME to profiler output
This commit is contained in:
parent
b77ffac4d4
commit
cde72f3710
@ -2,10 +2,12 @@ import logging
|
|||||||
import sys
|
import sys
|
||||||
|
|
||||||
from clan_vm_manager.app import MainApplication
|
from clan_vm_manager.app import MainApplication
|
||||||
|
from clan_vm_manager.components.profiler import profile
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@profile
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
app = MainApplication()
|
app = MainApplication()
|
||||||
return app.run(sys.argv)
|
return app.run(sys.argv)
|
||||||
|
@ -30,10 +30,10 @@ cProfile Output Columns Explanation:
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
def print_profile(profiler: cProfile.Profile) -> None:
|
def print_profile(profiler: cProfile.Profile, sortkey: pstats.SortKey) -> None:
|
||||||
s = io.StringIO()
|
s = io.StringIO()
|
||||||
ps = pstats.Stats(profiler, stream=s)
|
ps = pstats.Stats(profiler, stream=s)
|
||||||
ps.sort_stats(pstats.SortKey.CUMULATIVE)
|
ps.sort_stats(sortkey)
|
||||||
ps.print_stats(12)
|
ps.print_stats(12)
|
||||||
|
|
||||||
# Process the output to trim file paths
|
# Process the output to trim file paths
|
||||||
@ -60,6 +60,7 @@ def print_profile(profiler: cProfile.Profile) -> None:
|
|||||||
print(new_line)
|
print(new_line)
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Add an RLock for every profiler, currently not thread safe
|
||||||
class ProfilerStore:
|
class ProfilerStore:
|
||||||
profilers: dict[str, cProfile.Profile]
|
profilers: dict[str, cProfile.Profile]
|
||||||
|
|
||||||
@ -76,7 +77,8 @@ class ProfilerStore:
|
|||||||
def on_exit(self) -> None:
|
def on_exit(self) -> None:
|
||||||
for key, profiler in self.profilers.items():
|
for key, profiler in self.profilers.items():
|
||||||
print("=" * 7 + key + "=" * 7)
|
print("=" * 7 + key + "=" * 7)
|
||||||
print_profile(profiler)
|
print_profile(profiler, pstats.SortKey.TIME)
|
||||||
|
print_profile(profiler, pstats.SortKey.CUMULATIVE)
|
||||||
print(explanation)
|
print(explanation)
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ from clan_cli.history.add import HistoryEntry
|
|||||||
|
|
||||||
from clan_vm_manager import assets
|
from clan_vm_manager import assets
|
||||||
from clan_vm_manager.components.gkvstore import GKVStore
|
from clan_vm_manager.components.gkvstore import GKVStore
|
||||||
from clan_vm_manager.components.profiler import profile
|
|
||||||
from clan_vm_manager.components.vmobj import VMObject
|
from clan_vm_manager.components.vmobj import VMObject
|
||||||
|
|
||||||
gi.require_version("GObject", "2.0")
|
gi.require_version("GObject", "2.0")
|
||||||
@ -48,7 +47,6 @@ class ClanStore:
|
|||||||
self.push_history_entry(vm)
|
self.push_history_entry(vm)
|
||||||
return GLib.SOURCE_REMOVE
|
return GLib.SOURCE_REMOVE
|
||||||
|
|
||||||
@profile
|
|
||||||
def push_history_entry(self, entry: HistoryEntry) -> None:
|
def push_history_entry(self, entry: HistoryEntry) -> None:
|
||||||
# TODO: We shouldn't do this here but in the list view
|
# TODO: We shouldn't do this here but in the list view
|
||||||
if entry.flake.icon is None:
|
if entry.flake.icon is None:
|
||||||
|
Loading…
Reference in New Issue
Block a user