aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeon Scroggins III <scroggo@google.com>2022-05-12 12:13:27 -0400
committerLeon Scroggins <scroggo@google.com>2022-05-13 14:15:57 +0000
commit83b3283f01a883dbacd7f383a6693b827abec3ff (patch)
treeda22befd551d8f65742f75b3897420f2f7a3ee61
parent21e6e37ee325dcdb3fa99870138e386b330d5dc5 (diff)
downloadskia-83b3283f01a883dbacd7f383a6693b827abec3ff.tar.gz
Remove string copies in Skia tracing macros
ATRACE_ANDROID_FRAMEWORK_ALWAYS and TRACE_EVENT0_ALWAYS create a SkAndroidFrameworkTraceUtilAlways, which formats the input, requiring a string copy. Mimic the split in SkAndroidFrameworkTraceUtil, which has two constructors; one for formatting, and one for static strings. This allows skipping the copy when it's unnecessary. Make TRACE_EVENT0_ALWAYS call the cheaper constructor, since it never has formatted input. ATRACE_ANDROID_FRAMEWORK_ALWAYS has few callers; only one of them forces an unnecessary copy. Bug: b/224677119 Test: perfetto Change-Id: I8e699ae1496c94e08e6f7fce3616254b1a627a7f Reviewed-on: https://skia-review.googlesource.com/c/skia/+/539896 Commit-Queue: Leon Scroggins <scroggo@google.com> Reviewed-by: Herb Derby <herb@google.com> Reviewed-by: Brian Osman <brianosman@google.com> (cherry picked from commit e3772d2cae13ed606403aee8783825840a0dbd94) Reviewed-on: https://skia-review.googlesource.com/c/skia/+/540166 Auto-Submit: Leon Scroggins <scroggo@google.com>
-rw-r--r--src/core/SkTraceEventCommon.h8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/SkTraceEventCommon.h b/src/core/SkTraceEventCommon.h
index db46692415..b6495fba8a 100644
--- a/src/core/SkTraceEventCommon.h
+++ b/src/core/SkTraceEventCommon.h
@@ -118,7 +118,11 @@ private:
class SkAndroidFrameworkTraceUtilAlways {
public:
- SkAndroidFrameworkTraceUtilAlways(const char* fmt, ...) {
+ SkAndroidFrameworkTraceUtilAlways(const char* name) {
+ ATRACE_BEGIN(name);
+ }
+
+ SkAndroidFrameworkTraceUtilAlways(bool, const char* fmt, ...) {
if (!ATRACE_ENABLED()) return;
const int BUFFER_SIZE = 256;
@@ -137,7 +141,7 @@ public:
};
#define ATRACE_ANDROID_FRAMEWORK(fmt, ...) SkAndroidFrameworkTraceUtil __trace(true, fmt, ##__VA_ARGS__)
-#define ATRACE_ANDROID_FRAMEWORK_ALWAYS(fmt, ...) SkAndroidFrameworkTraceUtilAlways __trace_always(fmt, ##__VA_ARGS__)
+#define ATRACE_ANDROID_FRAMEWORK_ALWAYS(fmt, ...) SkAndroidFrameworkTraceUtilAlways __trace_always(true, fmt, ##__VA_ARGS__)
// Records a pair of begin and end events called "name" for the current scope, with 0, 1 or 2
// associated arguments. In the framework, the arguments are ignored.