Flutter Engine
fml::tracing Namespace Reference

Classes

class  ScopedInstantEnd
 
class  TraceFlow
 

Typedefs

using TraceArg = const char *
 
using TraceIDArg = int64_t
 

Functions

void TraceSetAllowlist (const std::vector< std::string > &allowlist)
 
size_t TraceNonce ()
 
void TraceTimelineEvent (TraceArg category_group, TraceArg name, int64_t timestamp_micros, TraceIDArg identifier, Dart_Timeline_Event_Type type, const std::vector< const char *> &c_names, const std::vector< std::string > &values)
 
void TraceTimelineEvent (TraceArg category_group, TraceArg name, TraceIDArg identifier, Dart_Timeline_Event_Type type, const std::vector< const char *> &c_names, const std::vector< std::string > &values)
 
void TraceEvent0 (TraceArg category_group, TraceArg name)
 
void TraceEvent1 (TraceArg category_group, TraceArg name, TraceArg arg1_name, TraceArg arg1_val)
 
void TraceEvent2 (TraceArg category_group, TraceArg name, TraceArg arg1_name, TraceArg arg1_val, TraceArg arg2_name, TraceArg arg2_val)
 
void TraceEventEnd (TraceArg name)
 
void TraceEventAsyncComplete (TraceArg category_group, TraceArg name, TimePoint begin, TimePoint end)
 
void TraceEventAsyncBegin0 (TraceArg category_group, TraceArg name, TraceIDArg id)
 
void TraceEventAsyncEnd0 (TraceArg category_group, TraceArg name, TraceIDArg id)
 
void TraceEventAsyncBegin1 (TraceArg category_group, TraceArg name, TraceIDArg id, TraceArg arg1_name, TraceArg arg1_val)
 
void TraceEventAsyncEnd1 (TraceArg category_group, TraceArg name, TraceIDArg id, TraceArg arg1_name, TraceArg arg1_val)
 
void TraceEventInstant0 (TraceArg category_group, TraceArg name)
 
void TraceEventInstant1 (TraceArg category_group, TraceArg name, TraceArg arg1_name, TraceArg arg1_val)
 
void TraceEventInstant2 (TraceArg category_group, TraceArg name, TraceArg arg1_name, TraceArg arg1_val, TraceArg arg2_name, TraceArg arg2_val)
 
void TraceEventFlowBegin0 (TraceArg category_group, TraceArg name, TraceIDArg id)
 
void TraceEventFlowStep0 (TraceArg category_group, TraceArg name, TraceIDArg id)
 
void TraceEventFlowEnd0 (TraceArg category_group, TraceArg name, TraceIDArg id)
 
std::string TraceToString (const char *string)
 
std::string TraceToString (std::string string)
 
std::string TraceToString (TimePoint point)
 
template<typename T , typename = std::enable_if_t<std::is_arithmetic<T>::value>>
std::string TraceToString (T string)
 
void SplitArgumentsCollect (std::vector< const char *> &keys, std::vector< std::string > &values)
 
template<typename Key , typename Value , typename... Args>
void SplitArgumentsCollect (std::vector< const char *> &keys, std::vector< std::string > &values, Key key, Value value, Args... args)
 
std::pair< std::vector< const char * >, std::vector< std::string > > SplitArguments ()
 
template<typename Key , typename Value , typename... Args>
std::pair< std::vector< const char * >, std::vector< std::string > > SplitArguments (Key key, Value value, Args... args)
 
template<typename... Args>
void TraceCounter (TraceArg category, TraceArg name, TraceIDArg identifier, Args... args)
 
template<typename... Args>
void TraceCounterNopHACK (TraceArg category, TraceArg name, TraceIDArg identifier, Args... args)
 
template<typename... Args>
void TraceEvent (TraceArg category, TraceArg name, Args... args)
 
template<typename... Args>
void TraceEventAsyncComplete (TraceArg category_group, TraceArg name, TimePoint begin, TimePoint end, Args... args)
 

Typedef Documentation

◆ TraceArg

using fml::tracing::TraceArg = typedef const char*

Definition at line 130 of file trace_event.h.

◆ TraceIDArg

using fml::tracing::TraceIDArg = typedef int64_t

Definition at line 131 of file trace_event.h.

Function Documentation

◆ SplitArguments() [1/2]

std::pair<std::vector<const char*>, std::vector<std::string> > fml::tracing::SplitArguments ( )
inline

Definition at line 182 of file trace_event.h.

Referenced by TraceCounter(), TraceEvent(), and TraceEventAsyncComplete().

182  {
183  return {};
184 }

◆ SplitArguments() [2/2]

template<typename Key , typename Value , typename... Args>
std::pair<std::vector<const char*>, std::vector<std::string> > fml::tracing::SplitArguments ( Key  key,
Value  value,
Args...  args 
)

Definition at line 188 of file trace_event.h.

References args, SplitArgumentsCollect(), and TraceNonce().

188  {
189  std::vector<const char*> keys;
190  std::vector<std::string> values;
191  SplitArgumentsCollect(keys, values, key, value, args...);
192  return std::make_pair(std::move(keys), std::move(values));
193 }
G_BEGIN_DECLS FlValue * args
void SplitArgumentsCollect(std::vector< const char *> &keys, std::vector< std::string > &values, Key key, Value value, Args... args)
Definition: trace_event.h:171
uint8_t value

◆ SplitArgumentsCollect() [1/2]

void fml::tracing::SplitArgumentsCollect ( std::vector< const char *> &  keys,
std::vector< std::string > &  values 
)
inline

Definition at line 167 of file trace_event.h.

Referenced by SplitArguments(), and SplitArgumentsCollect().

168  {}

◆ SplitArgumentsCollect() [2/2]

template<typename Key , typename Value , typename... Args>
void fml::tracing::SplitArgumentsCollect ( std::vector< const char *> &  keys,
std::vector< std::string > &  values,
Key  key,
Value  value,
Args...  args 
)

Definition at line 171 of file trace_event.h.

References args, SplitArgumentsCollect(), and TraceToString().

175  {
176  keys.emplace_back(key);
177  values.emplace_back(TraceToString(value));
178  SplitArgumentsCollect(keys, values, args...);
179 }
G_BEGIN_DECLS FlValue * args
std::string TraceToString(T string)
Definition: trace_event.h:163
void SplitArgumentsCollect(std::vector< const char *> &keys, std::vector< std::string > &values, Key key, Value value, Args... args)
Definition: trace_event.h:171
uint8_t value

◆ TraceCounter()

template<typename... Args>
void fml::tracing::TraceCounter ( TraceArg  category,
TraceArg  name,
TraceIDArg  identifier,
Args...  args 
)

Definition at line 198 of file trace_event.h.

References args, SplitArguments(), and TraceTimelineEvent().

201  {
202 #if FLUTTER_TIMELINE_ENABLED
203  auto split = SplitArguments(args...);
204  TraceTimelineEvent(category, name, identifier, Dart_Timeline_Event_Counter,
205  split.first, split.second);
206 #endif // FLUTTER_TIMELINE_ENABLED
207 }
G_BEGIN_DECLS FlValue * args
void TraceTimelineEvent(TraceArg category_group, TraceArg name, int64_t timestamp_micros, TraceIDArg identifier, Dart_Timeline_Event_Type type, const std::vector< const char *> &c_names, const std::vector< std::string > &values)
Definition: trace_event.cc:295
const char * name
Definition: fuchsia.cc:50
std::pair< std::vector< const char * >, std::vector< std::string > > SplitArguments(Key key, Value value, Args... args)
Definition: trace_event.h:188

◆ TraceCounterNopHACK()

template<typename... Args>
void fml::tracing::TraceCounterNopHACK ( TraceArg  category,
TraceArg  name,
TraceIDArg  identifier,
Args...  args 
)

Definition at line 212 of file trace_event.h.

215  {}

◆ TraceEvent()

template<typename... Args>
void fml::tracing::TraceEvent ( TraceArg  category,
TraceArg  name,
Args...  args 
)

Definition at line 218 of file trace_event.h.

References args, name, SplitArguments(), TraceEvent0(), TraceEvent1(), TraceEvent2(), TraceEventEnd(), and TraceTimelineEvent().

218  {
219 #if FLUTTER_TIMELINE_ENABLED
220  auto split = SplitArguments(args...);
221  TraceTimelineEvent(category, name, 0, Dart_Timeline_Event_Begin, split.first,
222  split.second);
223 #endif // FLUTTER_TIMELINE_ENABLED
224 }
G_BEGIN_DECLS FlValue * args
void TraceTimelineEvent(TraceArg category_group, TraceArg name, int64_t timestamp_micros, TraceIDArg identifier, Dart_Timeline_Event_Type type, const std::vector< const char *> &c_names, const std::vector< std::string > &values)
Definition: trace_event.cc:295
const char * name
Definition: fuchsia.cc:50
std::pair< std::vector< const char * >, std::vector< std::string > > SplitArguments(Key key, Value value, Args... args)
Definition: trace_event.h:188

◆ TraceEvent0()

void fml::tracing::TraceEvent0 ( TraceArg  category_group,
TraceArg  name 
)

◆ TraceEvent1()

void fml::tracing::TraceEvent1 ( TraceArg  category_group,
TraceArg  name,
TraceArg  arg1_name,
TraceArg  arg1_val 
)

Definition at line 312 of file trace_event.cc.

Referenced by TraceEvent().

315  {}

◆ TraceEvent2()

void fml::tracing::TraceEvent2 ( TraceArg  category_group,
TraceArg  name,
TraceArg  arg1_name,
TraceArg  arg1_val,
TraceArg  arg2_name,
TraceArg  arg2_val 
)

Definition at line 317 of file trace_event.cc.

Referenced by TraceEvent().

322  {}

◆ TraceEventAsyncBegin0()

void fml::tracing::TraceEventAsyncBegin0 ( TraceArg  category_group,
TraceArg  name,
TraceIDArg  id 
)

Definition at line 331 of file trace_event.cc.

Referenced by flutter::FlutterEventTracer::addTraceEvent(), and TraceEventAsyncComplete().

333  {}

◆ TraceEventAsyncBegin1()

void fml::tracing::TraceEventAsyncBegin1 ( TraceArg  category_group,
TraceArg  name,
TraceIDArg  id,
TraceArg  arg1_name,
TraceArg  arg1_val 
)

Definition at line 339 of file trace_event.cc.

Referenced by TraceEventAsyncComplete().

343  {}

◆ TraceEventAsyncComplete() [1/2]

template<typename... Args>
void fml::tracing::TraceEventAsyncComplete ( TraceArg  category_group,
TraceArg  name,
TimePoint  begin,
TimePoint  end,
Args...  args 
)

Definition at line 243 of file trace_event.h.

References args, SplitArguments(), fml::swap(), fml::TimePoint::ToEpochDelta(), fml::TimeDelta::ToMicroseconds(), TraceEventAsyncBegin0(), TraceEventAsyncBegin1(), TraceEventAsyncEnd0(), TraceEventAsyncEnd1(), TraceEventFlowBegin0(), TraceEventFlowEnd0(), TraceEventFlowStep0(), TraceEventInstant0(), TraceEventInstant1(), TraceEventInstant2(), TraceNonce(), and TraceTimelineEvent().

247  {
248 #if FLUTTER_TIMELINE_ENABLED
249  auto identifier = TraceNonce();
250  const auto split = SplitArguments(args...);
251 
252  if (begin > end) {
253  std::swap(begin, end);
254  }
255 
256  const int64_t begin_micros = begin.ToEpochDelta().ToMicroseconds();
257  const int64_t end_micros = end.ToEpochDelta().ToMicroseconds();
258 
259  TraceTimelineEvent(category_group, // group
260  name, // name
261  begin_micros, // timestamp_micros
262  identifier, // identifier
263  Dart_Timeline_Event_Async_Begin, // type
264  split.first, // names
265  split.second // values
266  );
267 
268  TraceTimelineEvent(category_group, // group
269  name, // name
270  end_micros, // timestamp_micros
271  identifier, // identifier
272  Dart_Timeline_Event_Async_End, // type
273  split.first, // names
274  split.second // values
275  );
276 #endif // FLUTTER_TIMELINE_ENABLED
277 }
G_BEGIN_DECLS FlValue * args
void TraceTimelineEvent(TraceArg category_group, TraceArg name, int64_t timestamp_micros, TraceIDArg identifier, Dart_Timeline_Event_Type type, const std::vector< const char *> &c_names, const std::vector< std::string > &values)
Definition: trace_event.cc:295
void swap(scoped_nsprotocol< C > &p1, scoped_nsprotocol< C > &p2)
const char * name
Definition: fuchsia.cc:50
size_t TraceNonce()
Definition: trace_event.cc:291
std::pair< std::vector< const char * >, std::vector< std::string > > SplitArguments(Key key, Value value, Args... args)
Definition: trace_event.h:188

◆ TraceEventAsyncComplete() [2/2]

void fml::tracing::TraceEventAsyncComplete ( TraceArg  category_group,
TraceArg  name,
TimePoint  begin,
TimePoint  end 
)

Definition at line 326 of file trace_event.cc.

Referenced by flutter::Rasterizer::Draw(), and flutter::FxlToDartOrEarlier().

329  {}

◆ TraceEventAsyncEnd0()

void fml::tracing::TraceEventAsyncEnd0 ( TraceArg  category_group,
TraceArg  name,
TraceIDArg  id 
)

Definition at line 335 of file trace_event.cc.

Referenced by flutter::FlutterEventTracer::addTraceEvent(), and TraceEventAsyncComplete().

337  {}

◆ TraceEventAsyncEnd1()

void fml::tracing::TraceEventAsyncEnd1 ( TraceArg  category_group,
TraceArg  name,
TraceIDArg  id,
TraceArg  arg1_name,
TraceArg  arg1_val 
)

Definition at line 345 of file trace_event.cc.

Referenced by TraceEventAsyncComplete().

349  {}

◆ TraceEventEnd()

◆ TraceEventFlowBegin0()

void fml::tracing::TraceEventFlowBegin0 ( TraceArg  category_group,
TraceArg  name,
TraceIDArg  id 
)

Definition at line 365 of file trace_event.cc.

Referenced by TraceEventAsyncComplete(), and fml::tracing::TraceFlow::TraceFlow().

367  {}

◆ TraceEventFlowEnd0()

void fml::tracing::TraceEventFlowEnd0 ( TraceArg  category_group,
TraceArg  name,
TraceIDArg  id 
)

Definition at line 373 of file trace_event.cc.

Referenced by fml::tracing::TraceFlow::End(), and TraceEventAsyncComplete().

373  {
374 }

◆ TraceEventFlowStep0()

void fml::tracing::TraceEventFlowStep0 ( TraceArg  category_group,
TraceArg  name,
TraceIDArg  id 
)

Definition at line 369 of file trace_event.cc.

Referenced by fml::tracing::TraceFlow::Step(), and TraceEventAsyncComplete().

371  {}

◆ TraceEventInstant0()

void fml::tracing::TraceEventInstant0 ( TraceArg  category_group,
TraceArg  name 
)

◆ TraceEventInstant1()

void fml::tracing::TraceEventInstant1 ( TraceArg  category_group,
TraceArg  name,
TraceArg  arg1_name,
TraceArg  arg1_val 
)

Definition at line 353 of file trace_event.cc.

Referenced by TraceEventAsyncComplete().

356  {}

◆ TraceEventInstant2()

void fml::tracing::TraceEventInstant2 ( TraceArg  category_group,
TraceArg  name,
TraceArg  arg1_name,
TraceArg  arg1_val,
TraceArg  arg2_name,
TraceArg  arg2_val 
)

Definition at line 358 of file trace_event.cc.

Referenced by TraceEventAsyncComplete().

363  {}

◆ TraceNonce()

size_t fml::tracing::TraceNonce ( )

◆ TraceSetAllowlist()

void fml::tracing::TraceSetAllowlist ( const std::vector< std::string > &  allowlist)

Definition at line 289 of file trace_event.cc.

Referenced by flutter::PerformInitializationTasks().

289 {}

◆ TraceTimelineEvent() [1/2]

void fml::tracing::TraceTimelineEvent ( TraceArg  category_group,
TraceArg  name,
int64_t  timestamp_micros,
TraceIDArg  identifier,
Dart_Timeline_Event_Type  type,
const std::vector< const char *> &  c_names,
const std::vector< std::string > &  values 
)

Definition at line 295 of file trace_event.cc.

Referenced by TraceCounter(), TraceEvent(), and TraceEventAsyncComplete().

301  {}

◆ TraceTimelineEvent() [2/2]

void fml::tracing::TraceTimelineEvent ( TraceArg  category_group,
TraceArg  name,
TraceIDArg  identifier,
Dart_Timeline_Event_Type  type,
const std::vector< const char *> &  c_names,
const std::vector< std::string > &  values 
)

Definition at line 303 of file trace_event.cc.

308  {}

◆ TraceToString() [1/4]

std::string fml::tracing::TraceToString ( const char *  string)
inline

Definition at line 150 of file trace_event.h.

Referenced by SplitArgumentsCollect().

150  {
151  return std::string{string};
152 }

◆ TraceToString() [2/4]

std::string fml::tracing::TraceToString ( std::string  string)
inline

Definition at line 154 of file trace_event.h.

154  {
155  return string;
156 }

◆ TraceToString() [3/4]

std::string fml::tracing::TraceToString ( TimePoint  point)
inline

Definition at line 158 of file trace_event.h.

References fml::TimePoint::ToEpochDelta(), fml::TimeDelta::ToNanoseconds(), and value.

158  {
159  return std::to_string(point.ToEpochDelta().ToNanoseconds());
160 }

◆ TraceToString() [4/4]

template<typename T , typename = std::enable_if_t<std::is_arithmetic<T>::value>>
std::string fml::tracing::TraceToString ( string)

Definition at line 163 of file trace_event.h.

163  {
164  return std::to_string(string);
165 }