diff options
Diffstat (limited to 'llvm/lib/Support/TimeProfiler.cpp')
-rw-r--r-- | llvm/lib/Support/TimeProfiler.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/llvm/lib/Support/TimeProfiler.cpp b/llvm/lib/Support/TimeProfiler.cpp index 6c7e8de..447ddf5a 100644 --- a/llvm/lib/Support/TimeProfiler.cpp +++ b/llvm/lib/Support/TimeProfiler.cpp @@ -89,6 +89,9 @@ struct TimeTraceProfiler { "All profiler sections should be ended when calling Write"); json::Array Events; + const size_t ExpectedEntryCount = + Entries.size() + CountAndTotalPerName.size() + 1; + Events.reserve(ExpectedEntryCount); // Emit all events for the main flame graph. for (const auto &E : Entries) { @@ -149,6 +152,8 @@ struct TimeTraceProfiler { {"args", json::Object{{"name", "clang"}}}, }); + assert(Events.size() == ExpectedEntryCount && "Size prediction failed!"); + OS << formatv("{0:2}", json::Value(json::Object( {{"traceEvents", std::move(Events)}}))); } |