pyinstrument if you have it
This commit is contained in:
parent
a665e1e31c
commit
f53879f961
1 changed files with 10 additions and 7 deletions
|
|
@ -1,6 +1,5 @@
|
||||||
import atexit
|
import atexit
|
||||||
|
|
||||||
from rich.console import Console
|
|
||||||
from typer import Typer
|
from typer import Typer
|
||||||
from websocket import create_connection
|
from websocket import create_connection
|
||||||
|
|
||||||
|
|
@ -62,10 +61,13 @@ class Client:
|
||||||
return self._ws
|
return self._ws
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
# from pyinstrument import Profiler
|
try:
|
||||||
|
from pyinstrument import Profiler
|
||||||
|
|
||||||
# profiler = Profiler()
|
profiler = Profiler()
|
||||||
# profiler.start()
|
profiler.start()
|
||||||
|
except ImportError:
|
||||||
|
profiler = None
|
||||||
while self.running:
|
while self.running:
|
||||||
console.print("running")
|
console.print("running")
|
||||||
console.print("handle_events")
|
console.print("handle_events")
|
||||||
|
|
@ -77,11 +79,12 @@ class Client:
|
||||||
time = self.clock.tick(60)
|
time = self.clock.tick(60)
|
||||||
self.elapsed = time / 100
|
self.elapsed = time / 100
|
||||||
self.ticks += 1
|
self.ticks += 1
|
||||||
Console().print(self.clock.get_fps())
|
# Console().print(self.clock.get_fps())
|
||||||
console.print(f"time: {time}")
|
console.print(f"time: {time}")
|
||||||
console.print(f"ticks: {self.ticks}")
|
console.print(f"ticks: {self.ticks}")
|
||||||
# profiler.stop()
|
if profiler:
|
||||||
# print(profiler.output_text())
|
profiler.stop()
|
||||||
|
print(profiler.output_text())
|
||||||
self.quit()
|
self.quit()
|
||||||
|
|
||||||
def quit(self):
|
def quit(self):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue