Skip to content

Commit e4732df

Browse files
committed
upgrade to asyncProfiler 4.4, simplify timestamp calculation in ProfileEventVisitor
1 parent 4ffeec8 commit e4732df

2 files changed

Lines changed: 2 additions & 9 deletions

File tree

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ androidxLifecycle = "2.2.0"
44
androidxNavigation = "2.4.2"
55
androidxTestCore = "1.7.0"
66
androidxCompose = "1.6.3"
7-
asyncProfiler = "4.2"
7+
asyncProfiler = "4.4"
88
composeCompiler = "1.5.14"
99
coroutines = "1.6.1"
1010
espresso = "3.7.0"

sentry-async-profiler/src/main/java/io/sentry/asyncprofiler/convert/JfrAsyncProfilerToSentryProfileConverter.java

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
@ApiStatus.Internal
2828
public final class JfrAsyncProfilerToSentryProfileConverter extends JfrConverter {
29-
private static final double NANOS_PER_SECOND = 1_000_000_000.0;
3029
private static final long UNKNOWN_THREAD_ID = -1;
3130

3231
private final @NotNull SentryProfile sentryProfile = new SentryProfile();
@@ -83,7 +82,6 @@ private class ProfileEventVisitor implements EventCollector.Visitor {
8382
private final @NotNull SentryStackTraceFactory stackTraceFactory;
8483
private final @NotNull JfrReader jfr;
8584
private final @NotNull Arguments args;
86-
private final double ticksPerNanosecond;
8785

8886
public ProfileEventVisitor(
8987
@NotNull SentryProfile sentryProfile,
@@ -94,7 +92,6 @@ public ProfileEventVisitor(
9492
this.stackTraceFactory = stackTraceFactory;
9593
this.jfr = jfr;
9694
this.args = args;
97-
ticksPerNanosecond = jfr.ticksPerSec / NANOS_PER_SECOND;
9895
}
9996

10097
@Override
@@ -150,11 +147,7 @@ private void processSampleWithStack(Event event, long threadId, StackTrace stack
150147
}
151148

152149
private double calculateTimestamp(Event event) {
153-
long nanosFromStart = (long) ((event.time - jfr.chunkStartTicks) / ticksPerNanosecond);
154-
155-
long timeNs = jfr.chunkStartNanos + nanosFromStart;
156-
157-
return DateUtils.nanosToSeconds(timeNs);
150+
return DateUtils.nanosToSeconds(jfr.eventTimeToNanos(event.time));
158151
}
159152

160153
private int addStackTrace(StackTrace stackTrace) {

0 commit comments

Comments
 (0)