blob: d2bc0627d951efecc3b538020c783bcf4322df1a [file] [log] [blame]
[email protected]5c6739c2013-07-15 23:33:291// 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
chrishtr82b5d9502017-03-20 18:25:335#ifndef CC_BENCHMARKS_BENCHMARK_INSTRUMENTATION_H_
6#define CC_BENCHMARKS_BENCHMARK_INSTRUMENTATION_H_
[email protected]5c6739c2013-07-15 23:33:297
chrishtr82b5d9502017-03-20 18:25:338#include "base/trace_event/trace_event.h"
chrishtrac41ff92017-03-17 05:07:309#include "cc/cc_export.h"
[email protected]adbe30f2013-10-11 21:12:3310#include "cc/debug/rendering_stats.h"
[email protected]5c6739c2013-07-15 23:33:2911
12namespace cc {
[email protected]1bbed7a2014-07-08 02:54:0013namespace benchmark_instrumentation {
[email protected]adbe30f2013-10-11 21:12:3314
[email protected]1bbed7a2014-07-08 02:54:0015// 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
19namespace internal {
Alexandr Ilin33126632018-11-14 14:48:1720constexpr 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]1bbed7a2014-07-08 02:54:0025const char kBeginFrameId[] = "begin_frame_id";
26} // namespace internal
27
khushalsagar0a226af2015-12-09 10:30:2028// TODO(khushalsagar): Fix these names for the telemetry benchmarks.
29// See crbug/567993.
[email protected]1bbed7a2014-07-08 02:54:0030const char kSendBeginFrame[] = "ThreadProxy::ScheduledActionSendBeginMainFrame";
31const char kDoBeginFrame[] = "ThreadProxy::BeginMainFrame";
32
33class ScopedBeginFrameTask {
[email protected]adbe30f2013-10-11 21:12:3334 public:
[email protected]1bbed7a2014-07-08 02:54:0035 ScopedBeginFrameTask(const char* event_name, unsigned int begin_frame_id)
36 : event_name_(event_name) {
Alexandr Ilin33126632018-11-14 14:48:1737 TRACE_EVENT_BEGIN1(internal::Category(), event_name_,
chrishtr82b5d9502017-03-20 18:25:3338 internal::kBeginFrameId, begin_frame_id);
[email protected]1bbed7a2014-07-08 02:54:0039 }
Vladimir Levinf06d1cd72019-03-13 18:24:1040 ScopedBeginFrameTask(const ScopedBeginFrameTask&) = delete;
[email protected]1bbed7a2014-07-08 02:54:0041 ~ScopedBeginFrameTask() {
Alexandr Ilin33126632018-11-14 14:48:1742 TRACE_EVENT_END0(internal::Category(), event_name_);
[email protected]1bbed7a2014-07-08 02:54:0043 }
44
Vladimir Levinf06d1cd72019-03-13 18:24:1045 ScopedBeginFrameTask& operator=(const ScopedBeginFrameTask&) = delete;
46
[email protected]1bbed7a2014-07-08 02:54:0047 private:
48 const char* event_name_;
[email protected]adbe30f2013-10-11 21:12:3349};
50
hendrikw3f7c2342014-11-08 01:59:2851void IssueImplThreadRenderingStatsEvent(const RenderingStats& stats);
jbauman477b5002014-10-06 18:14:2452void CC_EXPORT IssueDisplayRenderingStatsEvent();
[email protected]1bbed7a2014-07-08 02:54:0053
54} // namespace benchmark_instrumentation
[email protected]5c6739c2013-07-15 23:33:2955} // namespace cc
56
chrishtr82b5d9502017-03-20 18:25:3357#endif // CC_BENCHMARKS_BENCHMARK_INSTRUMENTATION_H_