From 779a399c59837e05ebac96307e2cb443585e5269 Mon Sep 17 00:00:00 2001 From: Thomas Adamcik Date: Tue, 24 Mar 2015 20:09:17 +0100 Subject: [PATCH] main: Use timer.time_logger helper --- mopidy/commands.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/mopidy/commands.py b/mopidy/commands.py index 5df8dd5a..ebb2c891 100644 --- a/mopidy/commands.py +++ b/mopidy/commands.py @@ -2,11 +2,9 @@ from __future__ import absolute_import, print_function, unicode_literals import argparse import collections -import contextlib import logging import os import sys -import time import glib @@ -15,7 +13,7 @@ import gobject from mopidy import config as config_lib, exceptions from mopidy.audio import Audio from mopidy.core import Core -from mopidy.utils import deps, process, versioning +from mopidy.utils import deps, process, timer, versioning logger = logging.getLogger(__name__) @@ -65,13 +63,6 @@ class _HelpAction(argparse.Action): raise _HelpError() -@contextlib.contextmanager -def _startup_timer(name): - start = time.time() - yield - logger.debug('%s startup took %dms', name, (time.time() - start) * 1000) - - class Command(object): """Command parser and runner for building trees of commands. @@ -356,7 +347,7 @@ class RootCommand(Command): backends = [] for backend_class in backend_classes: try: - with _startup_timer(backend_class.__name__): + with timer.time_logger(backend_class.__name__): backend = backend_class.start( config=config, audio=audio).proxy() backends.append(backend) @@ -379,7 +370,7 @@ class RootCommand(Command): for frontend_class in frontend_classes: try: - with _startup_timer(frontend_class.__name__): + with timer.time_logger(frontend_class.__name__): frontend_class.start(config=config, core=core) except exceptions.FrontendError as exc: logger.error(