Skip to content
Snippets Groups Projects
Commit eabe86fc authored by Frank Winklmeier's avatar Frank Winklmeier
Browse files

TrigPSC: Fix missing import and some cleanup

- Add missing IncludeError import
- Migrate ScopeTimer to std::chrono
- General cleanup


Former-commit-id: 96e07a3e
parent 427746eb
No related branches found
No related tags found
No related merge requests found
/* /*
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 * @file TrigPSC/Utils.h
* @author Frank Winklmeier * @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 * @brief Some helpers for the PSC
*/ */
...@@ -17,7 +14,7 @@ ...@@ -17,7 +14,7 @@
#include <vector> #include <vector>
#include <string> #include <string>
#include <sys/time.h> #include <chrono>
namespace psc { namespace psc {
...@@ -68,9 +65,9 @@ namespace psc { ...@@ -68,9 +65,9 @@ namespace psc {
void stop(); void stop();
private: private:
std::string m_descr; ///< description of timer std::string m_descr; ///< description of timer
struct timeval m_t1; ///< start time std::chrono::system_clock::time_point m_t1; ///< start time
bool m_running; ///< timer running? bool m_running; ///< timer running?
}; };
} /* namespace Utils */ } /* namespace Utils */
......
#
# 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')
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
## @file TrigPSCPythonDbSetup.py ## @file TrigPSCPythonDbSetup.py
## @brief Minimal Python setup for running from TrigDB ## @brief Minimal Python setup for running from TrigDB
## @author Frank Winklmeier ## @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 ## This is a very minimal Python setup. It is only included when
...@@ -12,9 +11,6 @@ ...@@ -12,9 +11,6 @@
## !!! Do NOT import theApp. It will screw up the configuration !!! ## !!! Do NOT import theApp. It will screw up the configuration !!!
import string, os, sys
def setTHistSvcOutput(): def setTHistSvcOutput():
"""Helper to set THistSvc.Output""" """Helper to set THistSvc.Output"""
......
...@@ -20,7 +20,9 @@ else: ...@@ -20,7 +20,9 @@ else:
pscServiceSetupBegin = "TrigServices/TrigServicesCommonBegin.py" # Service definitions pscServiceSetupBegin = "TrigServices/TrigServicesCommonBegin.py" # Service definitions
pscServiceSetupEnd = "TrigServices/TrigServicesCommonEnd.py" # Service definitions pscServiceSetupEnd = "TrigServices/TrigServicesCommonEnd.py" # Service definitions
import sys, os, string import sys
import os
import string
### Set up some common flags -------------------------------------------------- ### Set up some common flags --------------------------------------------------
...@@ -74,6 +76,9 @@ else: ...@@ -74,6 +76,9 @@ else:
del logLevel del logLevel
## file inclusion and tracing
from AthenaCommon.Include import Include, IncludeError, include
## set the default values ## set the default values
try: try:
include( pscBootstrapFile ) include( pscBootstrapFile )
...@@ -96,7 +101,7 @@ else: ...@@ -96,7 +101,7 @@ else:
# in case this is not available try for backward compatibility # in case this is not available try for backward compatibility
# to load the old libAthenaServicesDict and try to install it from there # 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 ServiceMgr.CoreDumpSvc.FatalHandler = -1 # make SIG_INT fatal
## set resource limits ## set resource limits
......
/* /*
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 * @file TrigPSC/src/Utils.cxx
* @author Frank Winklmeier * @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 * @brief Some helpers for the PSC
*/ */
...@@ -18,7 +15,6 @@ ...@@ -18,7 +15,6 @@
#undef _POSIX_C_SOURCE #undef _POSIX_C_SOURCE
#include <Python.h> #include <Python.h>
#include <sys/time.h>
#include <errno.h> #include <errno.h>
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
...@@ -59,35 +55,19 @@ bool psc::Utils::pyInclude (const std::string& pyFileName) ...@@ -59,35 +55,19 @@ bool psc::Utils::pyInclude (const std::string& pyFileName)
// ScopeTimer class // ScopeTimer class
//-------------------------------------------------------------------------------- //--------------------------------------------------------------------------------
psc::Utils::ScopeTimer::ScopeTimer (const std::string& descr) : psc::Utils::ScopeTimer::ScopeTimer (const std::string& descr) :
m_descr(descr), m_descr(descr),
m_running(true) m_running(true)
{ {
gettimeofday(&m_t1, 0); m_t1 = std::chrono::system_clock::now();
auto t = std::chrono::system_clock::to_time_t(m_t1);
// Format time ERS_LOG( m_descr << " started at time: " << std::put_time(std::localtime(&t), "%Y-%m-%d %H:%M:%S") );
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) );
} }
void psc::Utils::ScopeTimer::stop() void psc::Utils::ScopeTimer::stop()
{ {
struct timeval t2; auto t2 = std::chrono::system_clock::now();
gettimeofday(&t2, 0); auto dt_ms = std::chrono::duration_cast<std::chrono::milliseconds>(t2 - m_t1);
ERS_LOG( m_descr << " finished. Time used [ms] = " << dt_ms.count() );
int secs = 0 ; m_running = false;
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 );
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment