@@ -329,29 +329,39 @@ void KsDualMarkerSM::updateMarkers(const KsDataStore &data,
*/
void KsDualMarkerSM::updateLabels()
{
- QString mark, delta;
+ char separator(' ');
+ int precision(6); // 1 microsecond precision.
+
+ auto lamSetTimeLabel = [&precision, &separator] (QLabel &l, int64_t t) {
+ QString time = KsUtils::Ts2String(t, precision);
+ int i = time.indexOf('.') + 4;
+
+ /* Insert separators for milliseconds amd microseconds. */
+ while (i < time.size()) {
+ time.insert(i, separator);
+ i = i + 4;
+ }
+
+ l.setText(time);
+ };
// Marker A
- if (_markA._isSet) {
- mark = KsUtils::Ts2String(_markA._ts, 7);
- _labelMA.setText(mark);
- } else {
- _labelMA.setText("");
- }
+ if (_markA._isSet)
+ lamSetTimeLabel(_labelMA, _markA._ts);
+ else
+ _labelMA.clear();
// Marker B
- if (_markB._isSet) {
- mark = KsUtils::Ts2String(_markB._ts, 7);
- _labelMB.setText(mark);
- } else {
- _labelMB.setText("");
- }
+ if (_markB._isSet)
+ lamSetTimeLabel(_labelMB, _markB._ts);
+ else
+ _labelMB.clear();
// Delta
if (_markA._isSet && _markB._isSet) {
- delta = KsUtils::Ts2String(_markB._ts - _markA._ts, 7);
- _labelDelta.setText(delta);
+ precision = 9; // 1 nanoseconds precision.
+ lamSetTimeLabel(_labelDelta, _markB._ts - _markA._ts);
} else {
- _labelDelta.setText("");
+ _labelDelta.clear();
}
}
The precision of the displayed time of the two markers is set to 1 microsecond (as in the table). In the same time the precision of the time difference (Delta) is now 1 nanosecond, because we expect that the user do not care that much about the absolute time of the event, but may want to measure the interval between two events with the highest possible precision. The displayed time is formatted (spaces added) in a way that aims to make it easy to read the milliseconds and the microseconds. Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> --- kernel-shark/src/KsDualMarker.cpp | 42 +++++++++++++++++++------------ 1 file changed, 26 insertions(+), 16 deletions(-)