Mercurial > hg > Members > tobaru > cbc > CbC_llvm
comparison lib/Support/Statistic.cpp @ 77:54457678186b
LLVM 3.6
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 08 Sep 2014 22:06:00 +0900 |
parents | 95c75e76d11b |
children | afa8332a0e37 |
comparison
equal
deleted
inserted
replaced
34:e874dbf0ad9d | 77:54457678186b |
---|---|
82 Initialized = true; | 82 Initialized = true; |
83 TsanIgnoreWritesEnd(); | 83 TsanIgnoreWritesEnd(); |
84 } | 84 } |
85 } | 85 } |
86 | 86 |
87 namespace { | |
88 | |
89 struct NameCompare { | |
90 bool operator()(const Statistic *LHS, const Statistic *RHS) const { | |
91 int Cmp = std::strcmp(LHS->getName(), RHS->getName()); | |
92 if (Cmp != 0) return Cmp < 0; | |
93 | |
94 // Secondary key is the description. | |
95 return std::strcmp(LHS->getDesc(), RHS->getDesc()) < 0; | |
96 } | |
97 }; | |
98 | |
99 } | |
100 | |
101 // Print information when destroyed, iff command line option is specified. | 87 // Print information when destroyed, iff command line option is specified. |
102 StatisticInfo::~StatisticInfo() { | 88 StatisticInfo::~StatisticInfo() { |
103 llvm::PrintStatistics(); | 89 llvm::PrintStatistics(); |
104 } | 90 } |
105 | 91 |
122 MaxNameLen = std::max(MaxNameLen, | 108 MaxNameLen = std::max(MaxNameLen, |
123 (unsigned)std::strlen(Stats.Stats[i]->getName())); | 109 (unsigned)std::strlen(Stats.Stats[i]->getName())); |
124 } | 110 } |
125 | 111 |
126 // Sort the fields by name. | 112 // Sort the fields by name. |
127 std::stable_sort(Stats.Stats.begin(), Stats.Stats.end(), NameCompare()); | 113 std::stable_sort(Stats.Stats.begin(), Stats.Stats.end(), |
114 [](const Statistic *LHS, const Statistic *RHS) { | |
115 if (int Cmp = std::strcmp(LHS->getName(), RHS->getName())) | |
116 return Cmp < 0; | |
117 | |
118 // Secondary key is the description. | |
119 return std::strcmp(LHS->getDesc(), RHS->getDesc()) < 0; | |
120 }); | |
128 | 121 |
129 // Print out the statistics header... | 122 // Print out the statistics header... |
130 OS << "===" << std::string(73, '-') << "===\n" | 123 OS << "===" << std::string(73, '-') << "===\n" |
131 << " ... Statistics Collected ...\n" | 124 << " ... Statistics Collected ...\n" |
132 << "===" << std::string(73, '-') << "===\n\n"; | 125 << "===" << std::string(73, '-') << "===\n\n"; |