Skip to content

Conversation

@StefanSteiner
Copy link

Overview

This PR implements comprehensive microsecond timestamp support for the Tableau Log Viewer, including proper sorting, enhanced display formatting, and optimized copy functionality for data processing workflows. Hyper logs and soon, Tableau C++ logs, will have microsecond timestamps.

Features Implemented

🔍 Comprehensive Microsecond Support

  • Custom MicroTimestamp Class: New MicroTimestamp class (src/microtimestamp.h, src/microtimestamp.cpp) that preserves full 6-digit microsecond precision
  • Robust Parsing: Supports both microsecond (26-char) and millisecond (23-char) timestamp formats with automatic detection
  • Precise Sorting: Microsecond-level comparison operators ensure events are sorted correctly even within the same millisecond
  • Qt Integration: Full QVariant support with meta-type registration for seamless Qt model/view compatibility

📊 Enhanced Display & User Experience

  • Visual Formatting: Microsecond timestamps display as 12:34:56.123 456 with space separator for improved readability
  • Backward Compatibility: Millisecond timestamps continue to display as 12:34:56.123
  • Consistent Formatting: Maintains existing date/time display patterns across all time modes (GlobalDateTime, GlobalTime, TimeDeltas)
  • Performance Optimized: Efficient comparison algorithms with minimal memory overhead

📋 Smart Copy Functionality

  • Dual-Format Support:
    • Display: Shows 12:34:56.123 456 (with space for readability)
    • Copy: Provides 12:34:56.123456 (without space for data processing)
  • Copy Role Implementation: New Qt data role (Qt::UserRole + 1) specifically for copy operations
  • Universal Coverage: Enhanced copy functionality applies to all copy operations (Ctrl+C, Copy All Details, Export operations)

Technical Implementation

Core Components

  1. MicroTimestamp Class - Custom timestamp handling with microsecond precision
  2. TreeModel Enhancement - Updated data model with dual display/copy roles
  3. Copy Logic Optimization - Modified LogTab::CopyItemDetails() for intelligent timestamp handling
  4. Parsing Integration - Replaced parseTs() function to use MicroTimestamp objects throughout the system

Architecture Changes

  • Storage: TreeItem now stores MicroTimestamp objects via QVariant
  • Display: TreeModel::data() provides formatted display strings with space separators
  • Copy: TreeModel::data() with copy role provides clean strings without spaces
  • Sorting: Native MicroTimestamp comparison operators handle precise ordering
  • Compatibility: Graceful fallback to QDateTime for legacy timestamp handling

Files Modified

  • src/microtimestamp.h - New header for MicroTimestamp class
  • src/microtimestamp.cpp - Complete MicroTimestamp implementation
  • src/tableau-log-viewer.pro - Added new source files to build
  • src/treemodel.cpp - Enhanced data model with microsecond support and copy role
  • src/logtab.cpp - Updated copy functionality and time mode detection

Testing & Quality

  • Backward Compatibility: Existing millisecond logs continue to work unchanged
  • Performance: Optimized comparison algorithms maintain fast sorting
  • Memory Efficiency: Minimal overhead for microsecond storage
  • User Experience: Enhanced readability with maintained copy compatibility

Benefits

  • Data Accuracy: Preserves full microsecond precision from log files
  • Analysis Workflow: Copy operations provide clean data for spreadsheets and scripts
  • Visual Clarity: Space-separated display improves timestamp readability
  • Developer Friendly: Maintains API compatibility while adding new functionality
  • Performance: Efficient sorting of large log files with microsecond-level events

Before/After Comparison

Display

  • Before: 12:34:56.123 (truncated microseconds)
  • After: 12:34:56.123 456 (full precision with readable formatting)

Copy Operations

  • Before: Copied display format directly
  • After: Intelligent copy provides 12:34:56.123456 (clean format for data processing)

Sorting

  • Before: Events within same millisecond had undefined order
  • After: Perfect chronological ordering with microsecond precision

…now support sorting at microsecond level so when merging several logs together, they are properly merged at microsecond instead of millisecond granularity.
…t three digits of microsecond but remove the space when copying.
@StefanSteiner StefanSteiner changed the title Display microsecond timestampts if the log file has them Display microsecond timestamps if the log file has them Oct 3, 2025
Copy link
Contributor

@luiseeo luiseeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left come comments. Overall I like the changes, thanks for making TLV more useful :)

…reuse it. Also eliminated two unused functions
@StefanSteiner StefanSteiner marked this pull request as ready for review October 9, 2025 21:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants