[email protected] | 5c6739c | 2013-07-15 23:33:29 | [diff] [blame] | 1 | // Copyright 2013 The Chromium Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style license that can be | ||||
3 | // found in the LICENSE file. | ||||
4 | |||||
chrishtr | 82b5d950 | 2017-03-20 18:25:33 | [diff] [blame] | 5 | #ifndef CC_BENCHMARKS_BENCHMARK_INSTRUMENTATION_H_ |
6 | #define CC_BENCHMARKS_BENCHMARK_INSTRUMENTATION_H_ | ||||
[email protected] | 5c6739c | 2013-07-15 23:33:29 | [diff] [blame] | 7 | |
chrishtr | 82b5d950 | 2017-03-20 18:25:33 | [diff] [blame] | 8 | #include "base/trace_event/trace_event.h" |
chrishtr | ac41ff9 | 2017-03-17 05:07:30 | [diff] [blame] | 9 | #include "cc/cc_export.h" |
[email protected] | adbe30f | 2013-10-11 21:12:33 | [diff] [blame] | 10 | #include "cc/debug/rendering_stats.h" |
[email protected] | 5c6739c | 2013-07-15 23:33:29 | [diff] [blame] | 11 | |
12 | namespace cc { | ||||
[email protected] | 1bbed7a | 2014-07-08 02:54:00 | [diff] [blame] | 13 | namespace benchmark_instrumentation { |
[email protected] | adbe30f | 2013-10-11 21:12:33 | [diff] [blame] | 14 | |
[email protected] | 1bbed7a | 2014-07-08 02:54:00 | [diff] [blame] | 15 | // Please do not change the trace events in this file without updating |
16 | // tools/perf/measurements/rendering_stats.py accordingly. | ||||
17 | // The benchmarks search for events and their arguments by name. | ||||
18 | |||||
19 | namespace internal { | ||||
Alexandr Ilin | 3312663 | 2018-11-14 14:48:17 | [diff] [blame] | 20 | constexpr const char* Category() { |
21 | // Declared as a constexpr function to have an external linkage and to be | ||||
22 | // known at compile-time. | ||||
23 | return "cc,benchmark"; | ||||
24 | } | ||||
[email protected] | 1bbed7a | 2014-07-08 02:54:00 | [diff] [blame] | 25 | const char kBeginFrameId[] = "begin_frame_id"; |
26 | } // namespace internal | ||||
27 | |||||
khushalsagar | 0a226af | 2015-12-09 10:30:20 | [diff] [blame] | 28 | // TODO(khushalsagar): Fix these names for the telemetry benchmarks. |
29 | // See crbug/567993. | ||||
[email protected] | 1bbed7a | 2014-07-08 02:54:00 | [diff] [blame] | 30 | const char kSendBeginFrame[] = "ThreadProxy::ScheduledActionSendBeginMainFrame"; |
31 | const char kDoBeginFrame[] = "ThreadProxy::BeginMainFrame"; | ||||
32 | |||||
33 | class ScopedBeginFrameTask { | ||||
[email protected] | adbe30f | 2013-10-11 21:12:33 | [diff] [blame] | 34 | public: |
[email protected] | 1bbed7a | 2014-07-08 02:54:00 | [diff] [blame] | 35 | ScopedBeginFrameTask(const char* event_name, unsigned int begin_frame_id) |
36 | : event_name_(event_name) { | ||||
Alexandr Ilin | 3312663 | 2018-11-14 14:48:17 | [diff] [blame] | 37 | TRACE_EVENT_BEGIN1(internal::Category(), event_name_, |
chrishtr | 82b5d950 | 2017-03-20 18:25:33 | [diff] [blame] | 38 | internal::kBeginFrameId, begin_frame_id); |
[email protected] | 1bbed7a | 2014-07-08 02:54:00 | [diff] [blame] | 39 | } |
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 40 | ScopedBeginFrameTask(const ScopedBeginFrameTask&) = delete; |
[email protected] | 1bbed7a | 2014-07-08 02:54:00 | [diff] [blame] | 41 | ~ScopedBeginFrameTask() { |
Alexandr Ilin | 3312663 | 2018-11-14 14:48:17 | [diff] [blame] | 42 | TRACE_EVENT_END0(internal::Category(), event_name_); |
[email protected] | 1bbed7a | 2014-07-08 02:54:00 | [diff] [blame] | 43 | } |
44 | |||||
Vladimir Levin | f06d1cd7 | 2019-03-13 18:24:10 | [diff] [blame] | 45 | ScopedBeginFrameTask& operator=(const ScopedBeginFrameTask&) = delete; |
46 | |||||
[email protected] | 1bbed7a | 2014-07-08 02:54:00 | [diff] [blame] | 47 | private: |
48 | const char* event_name_; | ||||
[email protected] | adbe30f | 2013-10-11 21:12:33 | [diff] [blame] | 49 | }; |
50 | |||||
hendrikw | 3f7c234 | 2014-11-08 01:59:28 | [diff] [blame] | 51 | void IssueImplThreadRenderingStatsEvent(const RenderingStats& stats); |
jbauman | 477b500 | 2014-10-06 18:14:24 | [diff] [blame] | 52 | void CC_EXPORT IssueDisplayRenderingStatsEvent(); |
[email protected] | 1bbed7a | 2014-07-08 02:54:00 | [diff] [blame] | 53 | |
54 | } // namespace benchmark_instrumentation | ||||
[email protected] | 5c6739c | 2013-07-15 23:33:29 | [diff] [blame] | 55 | } // namespace cc |
56 | |||||
chrishtr | 82b5d950 | 2017-03-20 18:25:33 | [diff] [blame] | 57 | #endif // CC_BENCHMARKS_BENCHMARK_INSTRUMENTATION_H_ |