Skip to content

time_convert

Mario Bielert edited this page Jun 29, 2017 · 9 revisions

This class is used to convert timestamps from any clock to score-p measurement clock timestamps. A linear model is used to convert from the given clock to the measurement clock. Therefore the class needs exactly two synchronisation points.

Note:

  • This class can only be used, when the scorep_clock policy is used.

Usage

The usage of time_convert is parted into to two pieces.

First two synchronisation time points have to be set.

scorep::chrono::time_convert<> convert;
convert.synchronize_point();
// same time later...
convert.synchronize_point();

And then, the to_ticks() function is used to convert times.

auto some_time_point;

// it works for time points
auto time_in_ticks = convert.to_ticks(some_time_point);

auto other_time_point;

// ... and it works for durations
auto difference = convert.to_ticks(other_time_point - some_time_point);
auto reference_interval = convert.to_ticks(std::chrono::seconds(42));

Methods

time_convert()

The default constructor.

Note:

  • Requires, that synchronize_point() is called twice before the usage of to_ticks()

time_convert(local_time_point_t local_start, local_time_point_t local_stop, scorep::chrono::ticks scorep_start, scorep::chrono::ticks scorep_stop)

The extended constructor, which takes two synchronisations points as parameters.

This is equal to:

time_convert<> convert;
convert.synchronize_point(local_start, scorep_start);
convert.synchronize_point(local_stop, scorep_stop);

void synchronize_point(local_time_point_t local_tp = Clock::now(), scorep::chrono::ticks scorep_tp = measurement_clock::now())

Sets one synchronisation point.

Arguments:

local_tp - a time point of the given clock scorep_tp - the equivalent time point like local_tp, but in measurement clock ticks

Note:

  • This function can only be used, after the clock function handler was called from the plugin interface.
  • The sequence of function argument evaluation is undefined in the C++ standard. Thus the compiler is free to reorder the evaluation of the arguments.

bool is_synchronized()

Returns whether both synchronisation points were set or not.

Returns:

  • bool - true if both points are set, otherwise false

template <typename T> ticks to_ticks(const T t)

Converts the given chrono time_point or duration to ticks. As ticks don't have any notion about, whether they are meant as time_points or durations, this function only returns ticks.

Arguments:

  • t - the time_point or duration to be converted

Returns:

  • ticks - the resulting ticks

duration duration()

Returns the time between the two synchronization points as a duration of the given clock. This duration can be converted to ticks with the to_ticks() method.

Returns:

  • duration - the duration in local time
Clone this wiki locally