Skip to content
Snippets Groups Projects
Commit 96e07a3e 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
parent 56cbb0d3
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
* @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 */
......
#
# 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 @@
## @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"""
......
......@@ -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
......
/*
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;
}
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