From eabe86fc7b8dbaaffc296d53595365b6c028ae3f Mon Sep 17 00:00:00 2001 From: Frank Winklmeier <frank.winklmeier@cern.ch> Date: Mon, 26 Nov 2018 15:37:19 +0100 Subject: [PATCH] TrigPSC: Fix missing import and some cleanup - Add missing IncludeError import - Migrate ScopeTimer to std::chrono - General cleanup Former-commit-id: 96e07a3e9c3455fdf8afdebab78f6cec362c0700 --- .../TrigControl/TrigPSC/TrigPSC/Utils.h | 13 +++---- ...gHLTImplementationDBPythonSwitchToDebug.py | 10 ------ .../TrigPSC/share/TrigPSCPythonDbSetup.py | 4 --- .../TrigPSC/share/TrigPSCPythonSetup.py | 9 +++-- HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx | 36 +++++-------------- 5 files changed, 20 insertions(+), 52 deletions(-) delete mode 100644 HLT/Trigger/TrigControl/TrigPSC/share/TrigHLTImplementationDBPythonSwitchToDebug.py diff --git a/HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h b/HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h index ad8034838cc..fd58602034d 100644 --- a/HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h +++ b/HLT/Trigger/TrigControl/TrigPSC/TrigPSC/Utils.h @@ -1,13 +1,10 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ /** * @file TrigPSC/Utils.h * @author Frank Winklmeier - * $Author: ricab $ - * $Revision: 11 $ - * $Date: 2013-05-14 17:22:39 +0200 (Tue, 14 May 2013) $ * * @brief Some helpers for the PSC */ @@ -17,7 +14,7 @@ #include <vector> #include <string> -#include <sys/time.h> +#include <chrono> namespace psc { @@ -68,9 +65,9 @@ namespace psc { void stop(); private: - std::string m_descr; ///< description of timer - struct timeval m_t1; ///< start time - bool m_running; ///< timer running? + std::string m_descr; ///< description of timer + std::chrono::system_clock::time_point m_t1; ///< start time + bool m_running; ///< timer running? }; } /* namespace Utils */ diff --git a/HLT/Trigger/TrigControl/TrigPSC/share/TrigHLTImplementationDBPythonSwitchToDebug.py b/HLT/Trigger/TrigControl/TrigPSC/share/TrigHLTImplementationDBPythonSwitchToDebug.py deleted file mode 100644 index a3a53b18485..00000000000 --- a/HLT/Trigger/TrigControl/TrigPSC/share/TrigHLTImplementationDBPythonSwitchToDebug.py +++ /dev/null @@ -1,10 +0,0 @@ -# -# Switch Output Level to DEBUG when using HLTImplementationDBPython in OKS -# -from AthenaCommon.Include import include -from AthenaCommon.Constants import * -from TrigPSC import PscConfig -from TrigServices.TriggerUnixStandardSetup import _Conf -_Conf.useOnlineTHistSvc=True -PscConfig.optmap['LOGLEVEL']='DEBUG' -include('TrigPSC/TrigPSCPythonDbSetup.py') diff --git a/HLT/Trigger/TrigControl/TrigPSC/share/TrigPSCPythonDbSetup.py b/HLT/Trigger/TrigControl/TrigPSC/share/TrigPSCPythonDbSetup.py index e037fbfa326..e56abfb74e7 100644 --- a/HLT/Trigger/TrigControl/TrigPSC/share/TrigPSCPythonDbSetup.py +++ b/HLT/Trigger/TrigControl/TrigPSC/share/TrigPSCPythonDbSetup.py @@ -2,7 +2,6 @@ ## @file TrigPSCPythonDbSetup.py ## @brief Minimal Python setup for running from TrigDB ## @author Frank Winklmeier -## $Id: TrigPSCPythonDbSetup.py 11 2013-05-14 15:22:39Z ricab $ ############################################################### ## This is a very minimal Python setup. It is only included when @@ -12,9 +11,6 @@ ## !!! Do NOT import theApp. It will screw up the configuration !!! -import string, os, sys - - def setTHistSvcOutput(): """Helper to set THistSvc.Output""" diff --git a/HLT/Trigger/TrigControl/TrigPSC/share/TrigPSCPythonSetup.py b/HLT/Trigger/TrigControl/TrigPSC/share/TrigPSCPythonSetup.py index 4e049e14a61..c4bb4dedbbd 100755 --- a/HLT/Trigger/TrigControl/TrigPSC/share/TrigPSCPythonSetup.py +++ b/HLT/Trigger/TrigControl/TrigPSC/share/TrigPSCPythonSetup.py @@ -20,7 +20,9 @@ else: pscServiceSetupBegin = "TrigServices/TrigServicesCommonBegin.py" # Service definitions pscServiceSetupEnd = "TrigServices/TrigServicesCommonEnd.py" # Service definitions - import sys, os, string + import sys + import os + import string ### Set up some common flags -------------------------------------------------- @@ -74,6 +76,9 @@ else: del logLevel + ## file inclusion and tracing + from AthenaCommon.Include import Include, IncludeError, include + ## set the default values try: include( pscBootstrapFile ) @@ -96,7 +101,7 @@ else: # in case this is not available try for backward compatibility # to load the old libAthenaServicesDict and try to install it from there # - if ServiceMgr.CoreDumpSvc.properties().has_key('FatalHandler'): + if 'FatalHandler' in ServiceMgr.CoreDumpSvc.properties(): ServiceMgr.CoreDumpSvc.FatalHandler = -1 # make SIG_INT fatal ## set resource limits diff --git a/HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx b/HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx index b8f2d99bedf..2eddd12c15b 100644 --- a/HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx +++ b/HLT/Trigger/TrigControl/TrigPSC/src/Utils.cxx @@ -1,13 +1,10 @@ /* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration */ /** * @file TrigPSC/src/Utils.cxx * @author Frank Winklmeier - * $Author: ricab $ - * $Revision: 11 $ - * $Date: 2013-05-14 17:22:39 +0200 (Tue, 14 May 2013) $ * * @brief Some helpers for the PSC */ @@ -18,7 +15,6 @@ #undef _POSIX_C_SOURCE #include <Python.h> -#include <sys/time.h> #include <errno.h> //-------------------------------------------------------------------------------- @@ -59,35 +55,19 @@ bool psc::Utils::pyInclude (const std::string& pyFileName) // ScopeTimer class //-------------------------------------------------------------------------------- - psc::Utils::ScopeTimer::ScopeTimer (const std::string& descr) : m_descr(descr), m_running(true) { - gettimeofday(&m_t1, 0); - - // Format time - char buf[64]; - struct tm tms; - time_t sec = m_t1.tv_sec; - localtime_r(&sec, &tms); - strftime(buf, 64, "%Y-%m-%d %H:%M:%S", &tms); - - // Print and append milliseconds - ERS_LOG( m_descr << " started at time: " << buf - << "," << static_cast<unsigned int>(m_t1.tv_usec/1000) ); + m_t1 = std::chrono::system_clock::now(); + auto t = std::chrono::system_clock::to_time_t(m_t1); + ERS_LOG( m_descr << " started at time: " << std::put_time(std::localtime(&t), "%Y-%m-%d %H:%M:%S") ); } void psc::Utils::ScopeTimer::stop() { - struct timeval t2; - gettimeofday(&t2, 0); - - int secs = 0 ; - if (t2.tv_sec >= m_t1.tv_sec) - secs = t2.tv_sec - m_t1.tv_sec; - - int usecs = t2.tv_usec - m_t1.tv_usec; - float mtime = static_cast<float>(secs)*1000 + static_cast<float>(usecs)/1000; - ERS_LOG( m_descr << " finished. Time used [ms] = " << mtime ); + auto t2 = std::chrono::system_clock::now(); + auto dt_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - m_t1); + ERS_LOG( m_descr << " finished. Time used [ms] = " << dt_ms.count() ); + m_running = false; } -- GitLab