mirror of
https://github.com/dcs-retribution/dcs-retribution.git
synced 2025-11-10 15:41:24 +00:00
Add logged_duration context manager for profiling.
This commit is contained in:
@@ -7,18 +7,18 @@ from pathlib import Path
|
||||
from typing import Optional
|
||||
|
||||
import dcs
|
||||
from dcs.weapons_data import weapon_ids
|
||||
|
||||
from PySide2 import QtWidgets
|
||||
from PySide2.QtGui import QPixmap
|
||||
from PySide2.QtWidgets import QApplication, QSplashScreen
|
||||
from dcs.weapons_data import weapon_ids
|
||||
|
||||
from game import Game, db, persistency, VERSION
|
||||
from game import Game, VERSION, persistency
|
||||
from game.data.weapons import (
|
||||
WEAPON_FALLBACK_MAP,
|
||||
WEAPON_INTRODUCTION_YEARS,
|
||||
Weapon,
|
||||
)
|
||||
from game.profiling import logged_duration
|
||||
from game.settings import Settings
|
||||
from game.theater.start_generator import GameGenerator, GeneratorSettings
|
||||
from qt_ui import (
|
||||
@@ -228,15 +228,16 @@ def main():
|
||||
lint_weapon_data()
|
||||
|
||||
if args.subcommand == "new-game":
|
||||
game = create_game(
|
||||
args.campaign,
|
||||
args.blue,
|
||||
args.red,
|
||||
args.supercarrier,
|
||||
args.auto_procurement,
|
||||
args.inverted,
|
||||
args.cheats,
|
||||
)
|
||||
with logged_duration("New game creation"):
|
||||
game = create_game(
|
||||
args.campaign,
|
||||
args.blue,
|
||||
args.red,
|
||||
args.supercarrier,
|
||||
args.auto_procurement,
|
||||
args.inverted,
|
||||
args.cheats,
|
||||
)
|
||||
|
||||
run_ui(game)
|
||||
|
||||
|
||||
@@ -1,6 +1,3 @@
|
||||
import logging
|
||||
import timeit
|
||||
from datetime import timedelta
|
||||
from typing import List, Optional
|
||||
|
||||
from PySide2.QtWidgets import (
|
||||
@@ -15,10 +12,12 @@ from PySide2.QtWidgets import (
|
||||
import qt_ui.uiconstants as CONST
|
||||
from game import Game
|
||||
from game.event.airwar import AirWarEvent
|
||||
from game.profiling import logged_duration
|
||||
from gen.ato import Package
|
||||
from gen.flights.traveltime import TotEstimator
|
||||
from qt_ui.models import GameModel
|
||||
from qt_ui.widgets.QBudgetBox import QBudgetBox
|
||||
from qt_ui.widgets.QConditionsWidget import QConditionsWidget
|
||||
from qt_ui.widgets.QFactionsInfos import QFactionsInfos
|
||||
from qt_ui.widgets.QIntelBox import QIntelBox
|
||||
from qt_ui.widgets.clientslots import MaxPlayerCount
|
||||
@@ -27,7 +26,6 @@ from qt_ui.windows.PendingTransfersDialog import PendingTransfersDialog
|
||||
from qt_ui.windows.QWaitingForMissionResultWindow import QWaitingForMissionResultWindow
|
||||
from qt_ui.windows.settings.QSettingsWindow import QSettingsWindow
|
||||
from qt_ui.windows.stats.QStatsWindow import QStatsWindow
|
||||
from qt_ui.widgets.QConditionsWidget import QConditionsWidget
|
||||
|
||||
|
||||
class QTopPanel(QFrame):
|
||||
@@ -145,12 +143,10 @@ class QTopPanel(QFrame):
|
||||
self.dialog.show()
|
||||
|
||||
def passTurn(self):
|
||||
start = timeit.default_timer()
|
||||
self.game.pass_turn(no_action=True)
|
||||
GameUpdateSignal.get_instance().updateGame(self.game)
|
||||
self.proceedButton.setEnabled(True)
|
||||
end = timeit.default_timer()
|
||||
logging.info("Skipping turn took %s", timedelta(seconds=end - start))
|
||||
with logged_duration("Skipping turn"):
|
||||
self.game.pass_turn(no_action=True)
|
||||
GameUpdateSignal.get_instance().updateGame(self.game)
|
||||
self.proceedButton.setEnabled(True)
|
||||
|
||||
def negative_start_packages(self) -> List[Package]:
|
||||
packages = []
|
||||
|
||||
@@ -2,8 +2,6 @@ from __future__ import annotations
|
||||
|
||||
import json
|
||||
import os
|
||||
import timeit
|
||||
from datetime import timedelta
|
||||
from typing import Sized
|
||||
|
||||
from PySide2 import QtCore
|
||||
@@ -25,6 +23,7 @@ from jinja2 import Environment, FileSystemLoader, select_autoescape
|
||||
from game.debriefing import Debriefing, wait_for_debriefing
|
||||
from game.game import Event, Game, logging
|
||||
from game.persistency import base_path
|
||||
from game.profiling import logged_duration
|
||||
from game.unitmap import UnitMap
|
||||
from qt_ui.windows.GameUpdateSignal import GameUpdateSignal
|
||||
|
||||
@@ -205,14 +204,12 @@ class QWaitingForMissionResultWindow(QDialog):
|
||||
)
|
||||
|
||||
def process_debriefing(self):
|
||||
start = timeit.default_timer()
|
||||
self.game.finish_event(event=self.gameEvent, debriefing=self.debriefing)
|
||||
self.game.pass_turn()
|
||||
with logged_duration("Turn processing"):
|
||||
self.game.finish_event(event=self.gameEvent, debriefing=self.debriefing)
|
||||
self.game.pass_turn()
|
||||
|
||||
GameUpdateSignal.get_instance().sendDebriefing(self.debriefing)
|
||||
GameUpdateSignal.get_instance().updateGame(self.game)
|
||||
end = timeit.default_timer()
|
||||
logging.info("Turn processing took %s", timedelta(seconds=end - start))
|
||||
GameUpdateSignal.get_instance().sendDebriefing(self.debriefing)
|
||||
GameUpdateSignal.get_instance().updateGame(self.game)
|
||||
self.close()
|
||||
|
||||
def debriefing_directory_location(self) -> str:
|
||||
|
||||
Reference in New Issue
Block a user