[PATCH] D46939: [Timers] TimerGroup: add constructor from StringMap<TimeRecord>

Phabricator via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 16 11:20:15 PDT 2018


This revision was automatically updated to reflect the committed changes.
Closed by commit rL332506: [Timers] TimerGroup: add constructor from StringMap<TimeRecord> (authored by lebedevri, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46939?vs=147055&id=147140#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D46939

Files:
  llvm/trunk/include/llvm/Support/Timer.h
  llvm/trunk/lib/Support/Timer.cpp


Index: llvm/trunk/include/llvm/Support/Timer.h
===================================================================
--- llvm/trunk/include/llvm/Support/Timer.h
+++ llvm/trunk/include/llvm/Support/Timer.h
@@ -10,6 +10,7 @@
 #ifndef LLVM_SUPPORT_TIMER_H
 #define LLVM_SUPPORT_TIMER_H
 
+#include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/DataTypes.h"
 #include <cassert>
@@ -194,6 +195,10 @@
 
 public:
   explicit TimerGroup(StringRef Name, StringRef Description);
+
+  explicit TimerGroup(StringRef Name, StringRef Description,
+                      const StringMap<TimeRecord> &Records);
+
   ~TimerGroup();
 
   void setName(StringRef NewName, StringRef NewDescription) {
Index: llvm/trunk/lib/Support/Timer.cpp
===================================================================
--- llvm/trunk/lib/Support/Timer.cpp
+++ llvm/trunk/lib/Support/Timer.cpp
@@ -236,6 +236,15 @@
   TimerGroupList = this;
 }
 
+TimerGroup::TimerGroup(StringRef Name, StringRef Description,
+                       const StringMap<TimeRecord> &Records)
+    : TimerGroup(Name, Description) {
+  TimersToPrint.reserve(Records.size());
+  for (const auto &P : Records)
+    TimersToPrint.emplace_back(P.getValue(), P.getKey(), P.getKey());
+  assert(TimersToPrint.size() == Records.size() && "Size mismatch");
+}
+
 TimerGroup::~TimerGroup() {
   // If the timer group is destroyed before the timers it owns, accumulate and
   // print the timing data.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46939.147140.patch
Type: text/x-patch
Size: 1469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180516/d4a3e79c/attachment.bin>


More information about the cfe-commits mailing list