Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
a local clone.
dmd.timetrace
Compilation time tracing, -ftime-trace.
The time trace profile is output in the Chrome Trace Event Format, described
here: https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview
This file is originally from LDC (the LLVM D compiler).
Authors:
Johan Engelen, Max Haughton, Dennis Korpel
License:
Source common/timetrace.d
Documentation https://dlang.org/phobos/dmd_common_timetrace.html
- void
initializeTimeTrace(uinttimeGranularityUs, const(char)*processName); - Initialize time tracing functionality.Must be called before any other calls to timeTrace functions.Parameters:
uint timeGranularityUsminimum event size in microseconds const(char)* processNamename of this executable - void
deinitializeTimeTrace(); - Cleanup for time tracing functionality.After this, no more calls to timeTrace functions can be made.
- bool
timeTraceProfilerEnabled(); - Returns:Whether time tracing is enabled.
- void
writeTimeTraceProfile(OutBuffer*buf); - Write all time tracing results so far to JSON, in the Chrome Trace Event Format.Parameters:
OutBuffer* bufoutput buffer to write JSON into - void
timeTraceBeginEvent(scope const(char)*name_ptr, scope const(char)*detail_ptr, Locloc); - Start a new time trace event (C++ interface using upfront C-strings instead of lazy delegates)Parameters:
const(char)* name_ptrevent name, visible in high level profile view const(char)* detail_ptrfurther details, visible when this event is selected Loc locsource location corresponding to this event - void
timeTraceBeginEvent(TimeTraceEventTypeeventType); - Start a new time trace eventDetails of the event will be passed as delegates to timeTraceEndEvent so they're only generated when the event is actually written.Parameters:
TimeTraceEventType eventTypewhat compilation stage the event belongs to (redundant with the eventType of timeTraceEndEvent but used by GDC) - void
timeTraceEndEvent(TimeTraceEventTypeeventType);
voidtimeTraceEndEvent(TimeTraceEventTypeeventType, Dsymbolsym, scope const(char)[] delegate()detail= null);
voidtimeTraceEndEvent(TimeTraceEventTypeeventType, Expressione); - End a time tracing event, optionally updating the event name and details with a delegate. Delegates are used to prevent spending time on string generation when an event is too small to be generated anyway.Parameters:
TimeTraceEventType eventTypewhat compilation stage the event belongs to Dsymbol symDsymbol which was analyzed, used to generate 'name' and 'detail' Expression eExpression which was analyzed, used to generate 'name' and 'detail' const(char)[] delegate() detailcustom lazy string for 'detail' of event - enum
TimeTraceEventType: int; - Identifies which compilation stage the event is associated to
Copyright © 1999-2025 by the D Language Foundation | Page generated by
Ddoc on Mon Mar 31 10:27:43 2025