Skip to content
Snippets Groups Projects
Commit 978497ad authored by Tomasz Bold's avatar Tomasz Bold Committed by Tim Martin
Browse files

Add new class that represent a time stamp

Fixing issues from review by @fwinkl

Further review fixes


Former-commit-id: 09eeaa92
parent d342677a
No related branches found
No related tags found
8 merge requests!58791DataQualityConfigurations: Modify L1Calo config for web display,!46784MuonCondInterface: Enable thread-safety checking.,!46776Updated LArMonitoring config file for WD to match new files produced using MT,!45405updated ART test cron job,!42417Draft: DIRE and VINCIA Base Fragments for Pythia 8.3,!28528Revert 63f845ae,!27054Atr20369 210,!26342Monopole: Handle fractionally charged particles
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TrigTimeAlgs_TrigTimeStamp_h
#define TrigTimeAlgs_TrigTimeStamp_h
#include <chrono>
#include "SGTools/CLASS_DEF.h"
/**
* utility class to measure time duration in AthenaMT
* The pattern when it is useful:
* AlgA tags the beginning of the time period
*AlgA::execute() {
* timeStampHandle.record( std::move( std::make_unique<TrigTimeStamp>() ) ); }
*
* AlgB obtains the duration since the start tagged in AlgA:
* AlgB::execute() {
* double duration = timeStampHandle.cptr().milisecondsSince(); }
**/
class TrigTimeStamp {
public:
typedef std::chrono::high_resolution_clock::time_point stamp_type;
TrigTimeStamp()
: m_stamp( std::chrono::high_resolution_clock::now() ) {}
/**
* time duration between now and when the time stamp was created
**/
double millisecondsSince() const;
/**
* Obtain the stamp value.
**/
stamp_type get() const { return m_stamp; }
private:
stamp_type m_stamp;
};
CLASS_DEF( TrigTimeStamp , 262409323 , 1 )
#endif // TrigTimeAlgs_TrigTimeStamp_h
/*
Copyright (C) 2002-2018 CERN for the benefit of the ATLAS collaboration
*/
#include "TrigTimeAlgs/TrigTimeStamp.h"
double TrigTimeStamp::millisecondsSince() const {
return std::chrono::duration_cast<std::chrono::microseconds>( std::chrono::high_resolution_clock::now() - m_stamp ).count();
}
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