Commit 6027019d authored by Micha Müller's avatar Micha Müller
Browse files

Caliper patch: record timestamps with µs precision

parent 1124b762
......@@ -8,3 +8,16 @@
add_subdirectory(debug)
add_subdirectory(env)
add_subdirectory(event)
--- a/src/services/timestamp/Timestamp.cpp
+++ b/src/services/timestamp/Timestamp.cpp
@@ -208,7 +208,8 @@ class Timestamp
if (record_timestamp && (scope & CALI_SCOPE_PROCESS))
sbuf->append(timestamp_attr.id(),
- Variant(cali_make_variant_from_uint(chrono::system_clock::to_time_t(chrono::system_clock::now()))));
+ Variant(cali_make_variant_from_uint(
+ chrono::duration_cast<chrono::microseconds>(chrono::system_clock::now().time_since_epoch()).count())));
}
void post_init_cb(Caliper* c, Channel* chn) {
......@@ -166,11 +166,7 @@ void CaliperSensorGroup::read() {
reading_t reading;
reading.value = 1;
reading.timestamp = S_TO_NS(std::stoull(timestamp)); //Caliper timestamps are seconds since UNIX epoch
//a timestamp with a precision of seconds is not unique enough --> append current nanoseconds
uint64_t now_ns = getTimestamp() % 1000000000;
reading.timestamp += now_ns;
reading.timestamp = US_TO_NS(std::stoull(timestamp)); //Caliper timestamps are microseconds since UNIX epoch
S_Ptr s;
auto it = _sensorIndex.find(feName);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment