Skip to content

Commit f2ddd60

Browse files
[Support][Test] Time profiler: add regression test
Summary: Add output to `llvm::errs()` when `-ftime-trace` option is enabled, add regression test checking this option works as expected. Reviewers: thakis, aganea Subscribers: cfe-commits, llvm-commits Tags: #clang, #llvm Differential Revision: https://reviews.llvm.org/D61914 llvm-svn: 362792
1 parent 5d66f2b commit f2ddd60

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// RUN: %clangxx -ftime-trace %s 2>&1 | grep "Time trace json-file dumped to" \
2+
// RUN: | awk '{print $NF}' | xargs cat \
3+
// RUN: | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
4+
// RUN: | FileCheck %s
5+
6+
// CHECK: "traceEvents": [
7+
// CHECK: "args":
8+
// CHECK: "detail":
9+
// CHECK: "dur":
10+
// CHECK: "name": "Source"
11+
// CHECK-NEXT: "ph":
12+
// CHECK-NEXT: "pid":
13+
// CHECK-NEXT: "tid":
14+
// CHECK-NEXT: "ts":
15+
// CHECK: "name": "clang"
16+
// CHECK: "name": "process_name"
17+
18+
#include <iostream>
19+
20+
int main() {
21+
std::cout << "Foo" << std::endl;
22+
return 0;
23+
}

clang/tools/driver/cc1_main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@ int cc1_main(ArrayRef<const char *> Argv, const char *Argv0, void *MainAddr) {
241241

242242
llvm::timeTraceProfilerWrite(*profilerOutput);
243243
llvm::timeTraceProfilerCleanup();
244+
245+
llvm::errs() << "Time trace json-file dumped to " << Path.str() << "\n";
246+
llvm::errs()
247+
<< "Use chrome://tracing or Speedscope App "
248+
"(https://www.speedscope.app) for flamegraph visualization\n";
244249
}
245250

246251
// Our error handler depends on the Diagnostics object, which we're

0 commit comments

Comments
 (0)