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
5#ifndef CC_DEBUG_BENCHMARK_INSTRUMENTATION_H_
6#define CC_DEBUG_BENCHMARK_INSTRUMENTATION_H_
7
8#include "cc/debug/rendering_stats.h"
9
10namespace cc {
11namespace benchmark_instrumentation {
12
13// Please do not change the trace events in this file without updating
14// tools/perf/measurements/rendering_stats.py accordingly.
15// The benchmarks search for events and their arguments by name.
16
17namespace internal {
18const char kCategory[] = "cc,benchmark";
19const char kBeginFrameId[] = "begin_frame_id";
20}  // namespace internal
21
22const char kSendBeginFrame[] = "ThreadProxy::ScheduledActionSendBeginMainFrame";
23const char kDoBeginFrame[] = "ThreadProxy::BeginMainFrame";
24
25class ScopedBeginFrameTask {
26 public:
27  ScopedBeginFrameTask(const char* event_name, unsigned int begin_frame_id)
28      : event_name_(event_name) {
29    TRACE_EVENT_BEGIN1(internal::kCategory,
30                       event_name_,
31                       internal::kBeginFrameId,
32                       begin_frame_id);
33  }
34  ~ScopedBeginFrameTask() {
35    TRACE_EVENT_END0(internal::kCategory, event_name_);
36  }
37
38 private:
39  const char* event_name_;
40
41  DISALLOW_COPY_AND_ASSIGN(ScopedBeginFrameTask);
42};
43
44void IssueMainThreadRenderingStatsEvent(
45    const RenderingStats::MainThreadRenderingStats& stats);
46void IssueImplThreadRenderingStatsEvent(
47    const RenderingStats::ImplThreadRenderingStats& stats);
48
49}  // namespace benchmark_instrumentation
50}  // namespace cc
51
52#endif  // CC_DEBUG_BENCHMARK_INSTRUMENTATION_H_
53