0

I'm trying to solve a perf issue in my Android library. I use androidx.tracing to add trace events in system trace. My question is that should I use trace() or traceAsync() for a suspend function?

suspend fun foo() = traceAsync("foo", 0) { bar() }
suspend fun bar() = ...

According to the source code, trace() is a wrapper of beginSection/endSection, which need to execute on the same thread, it seems obvious I need to use traceAsync().

However, Gemini insists trace() is the right approach, on the other hand, ChatGPT/Claude/Grok said traceAsync() is correct.

I cannot find guidance from official document, and cannot find much references from public repos. Does anyone have experience which one I should use and why?

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.