netgen/libsrc/core/utils.cpp

41 lines
1.1 KiB
C++
Raw Normal View History

2019-01-02 22:38:03 +05:00
#include "utils.hpp"
2019-01-03 19:54:50 +05:00
#include "logging.hpp"
2019-01-02 22:38:03 +05:00
#ifndef WIN32
#include <cxxabi.h>
#endif
2019-01-03 19:54:50 +05:00
#include <iostream>
2019-01-02 22:38:03 +05:00
namespace ngcore
{
#ifdef WIN32
// windows does demangling in typeid(T).name()
NGCORE_API std::string Demangle(const char* typeinfo) { return typeinfo; }
#else
NGCORE_API std::string Demangle(const char* typeinfo) { int status; return abi::__cxa_demangle(typeinfo,
nullptr,
nullptr,
&status); }
2019-01-03 19:54:50 +05:00
double ticks_per_second = [] () noexcept
{
auto tick_start = GetTimeCounter();
double tstart = WallTime();
double tend = WallTime()+0.001;
// wait for 1ms and compare wall time with time counter
while(WallTime()<tend);
auto tick_end = GetTimeCounter();
tend = WallTime();
return (tick_end-tick_start)/(tend-tstart);
}();
const std::chrono::time_point<TClock> wall_time_start = TClock::now();
2019-01-02 22:38:03 +05:00
} // namespace ngcore
#endif