23 if ( stop_watch_sz ) {
24 for(
size_t sw_ndx = 0; sw_ndx < stop_watch_sz; ++sw_ndx ){
31 if( sw_ndx <
m_sw_vec.size() )
return;
33 for(
size_t sw_item_ndx =
m_sw_vec.size(); sw_item_ndx < sw_ndx; ++sw_item_ndx ){
38 std::map< std::string,CStopWatch >::iterator it =
m_sw_map.find( sw_name );
48 std::map< std::string,CStopWatch >::iterator it =
m_sw_map.find( sw_name );
63 if( sw_ndx >
m_sw_vec.size() )
return;
67 std::map< std::string,CStopWatch >::iterator it =
m_sw_map.find( sw_name );
107 m_user_data.push_back( std::make_pair( key_name, key_val) );
111 return m_sw_vec[ sw_ndx ].AsString (fmt);
115 std::map< std::string,CStopWatch >::const_iterator it =
m_sw_map.find( sw_name );
117 return m_sw_map[ sw_name ].AsString (fmt);
141 m_markers.push_back( std::make_pair ( new_marker, new_time_str ) );
152 string profile_log =
"blastapi_profile.csv";
153 char *env_ptr = getenv(
"BLASTAPI_PROFILE_LOG");
154 if( env_ptr ==
NULL )
return false;
156 report_name = profile_log;
158 profile_log =
string( env_ptr ) ;
165 std::ofstream log_ofs;
170 if (log_ofs.fail()) {
171 cerr <<
"Can't log profile data to the \""<< report_name<<
"\" errno: "
176 std::map< std::string,CStopWatch >::iterator item_itr;
179 std::list< std::pair< std::string, std::string >>::iterator user_it;
181 string key_val = user_it->second;
182 if( key_val.empty() ) key_val =
"NOT_SET";
183 log_ofs << user_it->first <<
" ," << key_val <<
", ";
187 log_ofs << item_itr->first
189 << item_itr->second.AsString (fmt)
199 report_name = report_name +
string(
".") + pid_str;
201 if (log_ofs.fail()) {
202 cerr <<
"Can't log profile data to the \""<< report_name<<
"\" errno: "
206 log_ofs <<
"#PID: "<<pid_str << endl;
207 std::list< std::pair <std::string, std::string> >::iterator it2;
209 log_ofs << it2->first <<
"," << it2->second << endl;
void AddUserKV(const std::string &key_name, bool bool_val)
std::list< std::pair< std::string, std::string > > m_user_data
static CRtProfiler * instance
void StopMT(size_t sw_ndx)
bool CheckDoReport(std::string &report_name)
void AddUserKVMT(const std::string &key_name, bool bool_val)
std::list< std::pair< std::string, std::string > > m_markers
CRtProfiler(size_t stop_watch_sz=0)
void AddMarkerMT(std::string new_marker)
void Start(size_t sw_ndx)
std::string AsStringMT(size_t sw_ndx, const CTimeFormat &fmt=kEmptyStr)
CFastMutex m_user_data_mx
std::map< std::string, CStopWatch > m_sw_map
bool DoReport(const CTimeFormat &fmt=kEmptyStr)
std::string AsString(size_t sw_ndx, const CTimeFormat &fmt=kEmptyStr)
void StartMT(size_t sw_ndx)
static CRtProfiler * getInstance()
std::vector< CStopWatch > m_sw_vec
void Allocate(size_t sw_ndx)
std::ofstream out("events_result.xml")
main entry point for tests
static TPid GetPid(void)
Get process identifier (pid) for the current process.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static int CompareNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive compare of a substring with another string.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
void Lock(void)
Acquire mutex for the current thread with no nesting checks.
void Unlock(void)
Release mutex with no owner or nesting checks.
string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const
Transform time to string.
@ eCurrent
Use current time. See also CCurrentTime.
Defines process management classes.
Defines classes: CDirEntry, CFile, CDir, CSymLink, CMemoryFile, CFileUtil, CFileLock,...