Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
vsyncprofiler.cc
Go to the documentation of this file.
1 
19 
20 #include <string>
21 
22 #include "ion/base/logging.h"
23 #include "ion/base/serialize.h"
25 #include "ion/profile/profiling.h"
26 
27 namespace ion {
28 namespace profile {
29 
32  return profiler;
33 }
34 
36  : VSyncProfiler(ion::profile::GetCallTraceManager()) {
37 }
38 
40  : vsync_trace_recorder_(manager->GetNamedTraceRecorder(
41  ion::profile::CallTraceManager::kRecorderVSync)),
42  last_vsync_timestamp_(0) {
43  DCHECK(vsync_trace_recorder_);
44 }
45 
46 void VSyncProfiler::RecordVSyncEvent(uint32 timestamp, uint32 vsync_number) {
48  if (timestamp < last_vsync_timestamp_) {
49  LOG_ONCE(WARNING) << "The timestamp needs to increase monotonically. "
50  << "Last: " << last_vsync_timestamp_ << ", "
51  << "current: " << timestamp;
52  return;
53  }
54  const std::string event_name = "VSync" + base::ValueToString(vsync_number);
55  vsync_trace_recorder_->CreateTimeStampAtTime(
56  timestamp, event_name.c_str(), nullptr);
57  last_vsync_timestamp_ = timestamp;
58 }
59 
60 } // namespace profile
61 } // namespace ion
#define ION_DECLARE_SAFE_STATIC_POINTER(type, variable)
Declare a static non-array pointer and calls a default constructor.
CallTraceManager * GetCallTraceManager()
Get the global, static instance of CallTraceManager.
Definition: profiling.cc:25
#define DCHECK(expr)
Definition: logging.h:331
void CreateTimeStampAtTime(uint32 timestamp, const char *name, const char *value)
Same as CreateTimeStamp, but with specified timestamp.
std::string ValueToString(const T &val)
ValueToString.
Definition: serialize.h:209
#define LOG_ONCE(severity)
Logs the streamed message once per process run with a severity of severity.
Definition: logging.h:219
static VSyncProfiler * Get()
Gets the VSyncProfiler singleton instance.
Copyright 2016 Google Inc.
Manages call trace recording for visualization in Web Tracing Framework (WTF) format.
Singleton class that augments CallTraceManager with VSync tracing support.
Definition: vsyncprofiler.h:39
void RecordVSyncEvent(uint32 timestamp, uint32 vsync_number)
Records a VSync event at given timestamp.