[PATCH] Add support for profiling the matchers used.

Samuel Benzaquen sbenza at google.com
Wed Oct 22 10:35:57 PDT 2014


================
Comment at: include/clang/ASTMatchers/ASTMatchFinder.h:123
@@ +122,3 @@
+      /// \brief Output for the report. If null, it prints to llvm::errs()
+      std::unique_ptr<llvm::raw_ostream> OS;
+    };
----------------
alexfh wrote:
> I'd prefer a more structured interface, e.g. a map from string to some struct containing collected timings + a method to convert this map to string or print it to a stream. Not sure if this fits well with LLVM timing facilities you use, though.
The current TimerGroup interface is a little awkward.
TimerGroup will print to llvm::errs() when the last timer is destroyed, unless you print() yourself to your own ostream.
I could skip the TimerGroup class and export the TimeRecords directly.
You could not use the TimerGroup printing logic, though. Most of it comes from TimeRecord anyway, so it wouldn't be that bad.

So, would you prefer if this was:

struct ProfileChecks {
  llvm::StringMap<llvm::TimeRecord> *Records;
};

?

================
Comment at: lib/ASTMatchers/ASTMatchFinder.cpp:315
@@ -300,1 +314,3 @@
+      llvm::TimeRegion Timer(
+          EnableCheckProfiling ? getTimerForBucket(MC->getID()) : nullptr);
       MC->onStartOfTranslationUnit();
----------------
alexfh wrote:
> You can check EnableCheckProfiling inside getTimerForBucket to reduce code repetition.
I put it outside to avoid calling the function when disabled.

http://reviews.llvm.org/D5911






More information about the cfe-commits mailing list