Flutter Engine
fml::tracing Namespace Reference

Classes

class  ScopedInstantEnd
 
class  TraceFlow
 

Typedefs

using TraceArg = const char *
 
using TraceIDArg = int64_t
 
using TimelineEventHandler = std::function< void(const char *, int64_t, int64_t, Dart_Timeline_Event_Type, intptr_t, const char **, const char **)>
 

Functions

void TraceSetAllowlist (const std::vector< std::string > &allowlist)
 
void TraceSetTimelineEventHandler (TimelineEventHandler handler)
 
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

◆ TimelineEventHandler

using fml::tracing::TimelineEventHandler = typedef std::function<void(const char*, int64_t, int64_t, Dart_Timeline_Event_Type, intptr_t, const char**, const char**)>

Definition at line 156 of file trace_event.h.

◆ TraceArg

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

Definition at line 145 of file trace_event.h.

◆ TraceIDArg

using fml::tracing::TraceIDArg = typedef int64_t

Definition at line 146 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 207 of file trace_event.h.

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

207  {
208  return {};
209 }

◆ 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 213 of file trace_event.h.

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

213  {
214  std::vector<const char*> keys;
215  std::vector<std::string> values;
216  SplitArgumentsCollect(keys, values, key, value, args...);
217  return std::make_pair(std::move(keys), std::move(values));
218 }
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:196
uint8_t value

◆ SplitArgumentsCollect() [1/2]

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

Definition at line 192 of file trace_event.h.

Referenced by SplitArguments(), and SplitArgumentsCollect().

193  {}

◆ 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 196 of file trace_event.h.

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

200  {
201  keys.emplace_back(key);
202  values.emplace_back(TraceToString(value));
203  SplitArgumentsCollect(keys, values, args...);
204 }
G_BEGIN_DECLS FlValue * args
std::string TraceToString(T string)
Definition: trace_event.h:188
void SplitArgumentsCollect(std::vector< const char *> &keys, std::vector< std::string > &values, Key key, Value value, Args... args)
Definition: trace_event.h:196
uint8_t value

◆ TraceCounter()

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

Definition at line 223 of file trace_event.h.

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

226  {
227 #if FLUTTER_TIMELINE_ENABLED
228  auto split = SplitArguments(args...);
229  TraceTimelineEvent(category, name, identifier, Dart_Timeline_Event_Counter,
230  split.first, split.second);
231 #endif // FLUTTER_TIMELINE_ENABLED
232 }
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:302
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:213

◆ TraceCounterNopHACK()

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

Definition at line 237 of file trace_event.h.

240  {}

◆ TraceEvent()

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

Definition at line 243 of file trace_event.h.

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

243  {
244 #if FLUTTER_TIMELINE_ENABLED
245  auto split = SplitArguments(args...);
246  TraceTimelineEvent(category, name, 0, Dart_Timeline_Event_Begin, split.first,
247  split.second);
248 #endif // FLUTTER_TIMELINE_ENABLED
249 }
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:302
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:213

◆ 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 319 of file trace_event.cc.

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

322  {}

◆ 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 324 of file trace_event.cc.

Referenced by TraceEvent().

329  {}

◆ TraceEventAsyncBegin0()

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

Definition at line 338 of file trace_event.cc.

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

340  {}

◆ TraceEventAsyncBegin1()

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

Definition at line 346 of file trace_event.cc.

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

350  {}

◆ TraceEventAsyncComplete() [1/2]

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

Definition at line 268 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().

272  {
273 #if FLUTTER_TIMELINE_ENABLED
274  auto identifier = TraceNonce();
275  const auto split = SplitArguments(args...);
276 
277  if (begin > end) {
278  std::swap(begin, end);
279  }
280 
281  const int64_t begin_micros = begin.ToEpochDelta().ToMicroseconds();
282  const int64_t end_micros = end.ToEpochDelta().ToMicroseconds();
283 
284  TraceTimelineEvent(category_group, // group
285  name, // name
286  begin_micros, // timestamp_micros
287  identifier, // identifier
288  Dart_Timeline_Event_Async_Begin, // type
289  split.first, // names
290  split.second // values
291  );
292 
293  TraceTimelineEvent(category_group, // group
294  name, // name
295  end_micros, // timestamp_micros
296  identifier, // identifier
297  Dart_Timeline_Event_Async_End, // type
298  split.first, // names
299  split.second // values
300  );
301 #endif // FLUTTER_TIMELINE_ENABLED
302 }
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:302
void swap(scoped_nsprotocol< C > &p1, scoped_nsprotocol< C > &p2)
const char * name
Definition: fuchsia.cc:50
size_t TraceNonce()
Definition: trace_event.cc:298
std::pair< std::vector< const char * >, std::vector< std::string > > SplitArguments(Key key, Value value, Args... args)
Definition: trace_event.h:213

◆ TraceEventAsyncComplete() [2/2]

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

Definition at line 333 of file trace_event.cc.

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

336  {}

◆ TraceEventAsyncEnd0()

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

Definition at line 342 of file trace_event.cc.

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

344  {}

◆ TraceEventAsyncEnd1()

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

Definition at line 352 of file trace_event.cc.

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

356  {}

◆ TraceEventEnd()

◆ TraceEventFlowBegin0()

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

Definition at line 372 of file trace_event.cc.

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

374  {}

◆ TraceEventFlowEnd0()

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

Definition at line 380 of file trace_event.cc.

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

380  {
381 }

◆ TraceEventFlowStep0()

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

Definition at line 376 of file trace_event.cc.

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

378  {}

◆ 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 360 of file trace_event.cc.

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

363  {}

◆ 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 365 of file trace_event.cc.

Referenced by TraceEventAsyncComplete().

370  {}

◆ TraceNonce()

size_t fml::tracing::TraceNonce ( )

◆ TraceSetAllowlist()

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

Definition at line 294 of file trace_event.cc.

294 {}

◆ TraceSetTimelineEventHandler()

void fml::tracing::TraceSetTimelineEventHandler ( TimelineEventHandler  handler)

Definition at line 296 of file trace_event.cc.

Referenced by DartVMInitializer::Initialize().

296 {}

◆ 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 302 of file trace_event.cc.

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

308  {}

◆ 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 310 of file trace_event.cc.

315  {}

◆ TraceToString() [1/4]

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

Definition at line 175 of file trace_event.h.

Referenced by SplitArgumentsCollect().

175  {
176  return std::string{string};
177 }

◆ TraceToString() [2/4]

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

Definition at line 179 of file trace_event.h.

179  {
180  return string;
181 }

◆ TraceToString() [3/4]

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

Definition at line 183 of file trace_event.h.

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

183  {
184  return std::to_string(point.ToEpochDelta().ToNanoseconds());
185 }

◆ 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 188 of file trace_event.h.

188  {
189  return std::to_string(string);
190 }