Skip to content

Commit

Permalink
Add frequency to CTFTmfTrace properties
Browse files Browse the repository at this point in the history
The frequency of the CtfTmfTrace is currently exposed in an indirect way using cyclesToNanos(). But sometimes there is the need to get direct frequency in trace properties. This commit added public methods to get the direct frequency and added them to the properties of the trace.

[Added] frequency in getProperties() in CTFTmfTrace
[Added] public method to get frequency in CTFClock and CTFTrace
  • Loading branch information
Siwei Zhang committed Sep 24, 2024
1 parent 945b92e commit aa91f94
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,10 @@ public boolean isClockScaled() {
return fIsScaled;
}

/**
* @return the frequency in Hz
*/
public long getFrequency() {
return ((Long) getProperty(FREQ));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -832,6 +832,18 @@ public final long getOffset() {
return fSingleClock.getClockOffset();
}

/**
* Gets the frequency
*
* @return the frequency
*/
public final long getFrequency() {
if (getClock() == null) {
return 0;
}
return fSingleClock.getFrequency();
}

/**
* Gets the time scale in nanoseconds/cycle
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ public class CtfTmfTrace extends TmfTrace
* @since 1.2
*/
public static final String CLOCK_OFFSET = "clock_offset"; //$NON-NLS-1$
public static final String CLOCK_FREQUENCY = "frequency"; //$NON-NLS-1$

/**
* Default cache size for CTF traces
Expand Down Expand Up @@ -585,6 +586,7 @@ public Map<String, String> getProperties() {
}
properties.putAll(trace.getEnvironment());
properties.put(CLOCK_OFFSET, Long.toUnsignedString(trace.getOffset()));
properties.put(CLOCK_FREQUENCY, Long.toUnsignedString(trace.getFrequency()));
properties.put(Messages.CtfTmfTrace_HostID, getHostId());
return properties;
}
Expand Down

0 comments on commit aa91f94

Please sign in to comment.