mirror of
https://github.com/dlang/dmd.git
synced 2025-04-26 13:10:12 +03:00

* Add --ftime-trace to dmd * Refactor timetrace code for dmd. Pass Outbuffer by ref, move timetrace filename logic to main.d
28 lines
829 B
D
28 lines
829 B
D
/**
|
|
The output of -ftime-trace is not deterministic because it contains timer data,
|
|
and it's also full of implementation details (such as the order of semantic analysis).
|
|
In order to test the output, this program extracts only 'name' and 'details' strings of events,
|
|
and sorts them, so the output can be tested.
|
|
*/
|
|
module sanitize_timetrace;
|
|
|
|
import std.algorithm;
|
|
import std.array;
|
|
import std.conv;
|
|
import std.json;
|
|
import std.range;
|
|
import std.string;
|
|
|
|
void sanitizeTimeTrace(ref string testOutput)
|
|
{
|
|
parseJSON(testOutput);
|
|
auto json = parseJSON(testOutput);
|
|
string result = json["traceEvents"].array
|
|
.filter!(x => x["ph"].str == "X")
|
|
.map!(x => strip(x["name"].str ~ ", " ~ x["args"]["detail"].str))
|
|
.array
|
|
.sort
|
|
.uniq
|
|
.joiner("\n").text;
|
|
testOutput = result;
|
|
}
|