Skip to content

Commit acf9a70

Browse files
committed
feat(perf-ktx): add trace(name, block) extension function
1 parent fa4adcf commit acf9a70

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

firebase-perf/ktx/api.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ package com.google.firebase.perf.ktx {
55
method @NonNull public static com.google.firebase.perf.FirebasePerformance getPerformance(@NonNull com.google.firebase.ktx.Firebase);
66
method public static inline void trace(@NonNull com.google.firebase.perf.metrics.HttpMetric, @NonNull kotlin.jvm.functions.Function1<? super com.google.firebase.perf.metrics.HttpMetric,kotlin.Unit> block);
77
method public static inline <T> T trace(@NonNull com.google.firebase.perf.metrics.Trace, @NonNull kotlin.jvm.functions.Function1<? super com.google.firebase.perf.metrics.Trace,? extends T> block);
8+
method public static inline <T> T trace(@NonNull String name, @NonNull kotlin.jvm.functions.Function1<? super com.google.firebase.perf.metrics.Trace,? extends T> block);
89
}
910

1011
}

firebase-perf/ktx/src/main/kotlin/com/google/firebase/perf/ktx/Performance.kt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,12 @@ inline fun <T> Trace.trace(block: Trace.() -> T): T {
4848
}
4949
}
5050

51+
/**
52+
* Creates a [Trace] object with given [name] and measures the time it takes to
53+
* run the [block] wrapped by calls to [start] and [stop].
54+
*/
55+
inline fun <T> trace(name: String, block: Trace.() -> T): T = Trace.create(name).trace(block)
56+
5157
internal const val LIBRARY_NAME: String = "fire-perf-ktx"
5258

5359
/** @suppress */

0 commit comments

Comments
 (0)