Use llvm::json::Array.reserve() to optimize json output time. Here is motivation:
https://reviews.llvm.org/D60609#1468941. In short: for the json array
with ~32K entries, pushing back each entry takes ~4% of whole time compared
to the method of preliminary memory reservation: (3995-3845)/3995 = 3.75%.
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
- Build Status
Buildable 30638 Build 30637: arc lint + arc unit
Event Timeline
Comment Actions
LG, thank you.
llvm/lib/Support/TimeProfiler.cpp | ||
---|---|---|
92 | Just do const size_t ExpectedEntryCount = Entries.size() + CountAndTotalPerName.size() + 1; Events.reserve(ExpectedEntryCount); ... assert(Events.size() == ExpectedEntryCount && "Size prediction failed"); else they could drift apart. |
llvm/lib/Support/TimeProfiler.cpp | ||
---|---|---|
92 | Thanks, good point! |
Just do
else they could drift apart.