Merge branch 'tsc_timers' into 'master'

Use rdtsc in Timers

See merge request jschoeberl/netgen!260
This commit is contained in:
Joachim Schöberl 2019-10-01 11:49:13 +00:00
commit 44486866b5
4 changed files with 9 additions and 9 deletions

View File

@ -98,7 +98,7 @@ namespace ngcore
// return time in milliseconds as double
// return std::chrono::duration<double>(t-start_time).count()*1000.0;
// return std::chrono::duration<double>(t-start_time).count() / 2.7e3;
return 1000.0*static_cast<double>(t-start_time) / ticks_per_second;
return 1000.0*static_cast<double>(t-start_time) * seconds_per_tick;
}
enum PType
@ -629,7 +629,7 @@ namespace ngcore
std::sort (events.begin(), events.end());
root.time = 1000.0*static_cast<double>(stop_time-start_time)/ticks_per_second;
root.time = 1000.0*static_cast<double>(stop_time-start_time) * seconds_per_tick;
for(auto & event : events)
{
@ -658,7 +658,7 @@ namespace ngcore
std::cout << "node stack empty!" << std::endl;
break;
}
double time = 1000.0*static_cast<double>(event.time-current->start_time)/ticks_per_second;
double time = 1000.0*static_cast<double>(event.time-current->start_time) * seconds_per_tick;
current->time += time;
current = node_stack.back();
current->time -= time;

View File

@ -22,7 +22,7 @@ namespace ngcore
TimerVal() = default;
double tottime = 0.0;
double starttime = 0.0;
TTimePoint starttime=0;
double flops = 0.0;
double loads = 0.0;
double stores = 0.0;
@ -61,13 +61,13 @@ namespace ngcore
/// start timer of index nr
static void StartTimer (int nr)
{
timers[nr].starttime = WallTime(); timers[nr].count++;
timers[nr].starttime = GetTimeCounter(); timers[nr].count++;
}
/// stop timer of index nr
static void StopTimer (int nr)
{
timers[nr].tottime += WallTime()-timers[nr].starttime;
timers[nr].tottime += (GetTimeCounter()-timers[nr].starttime)*seconds_per_tick;
}
static void StartThreadTimer (size_t nr, size_t tid)

View File

@ -21,7 +21,7 @@ namespace ngcore
&status); }
#endif
double ticks_per_second = [] () noexcept
double seconds_per_tick = [] () noexcept
{
auto tick_start = GetTimeCounter();
double tstart = WallTime();
@ -33,7 +33,7 @@ namespace ngcore
auto tick_end = GetTimeCounter();
tend = WallTime();
return static_cast<double>(tick_end-tick_start)/(tend-tstart);
return (tend-tstart)/static_cast<double>(tick_end-tick_start);
}();
const std::chrono::time_point<TClock> wall_time_start = TClock::now();

View File

@ -44,7 +44,7 @@ namespace ngcore
// High precision clock counter register
using TTimePoint = size_t;
extern NGCORE_API double ticks_per_second;
extern NGCORE_API double seconds_per_tick;
inline TTimePoint GetTimeCounter() noexcept
{