@@ -141,7 +141,9 @@ static std::pair<Duration, Duration> measure(llvm::function_ref<void()> body) {
141
141
auto tEnd = std::chrono::steady_clock::now ();
142
142
143
143
auto clockMultiply =
144
- Duration::period::den / CLOCKS_PER_SEC / Duration::period::num;
144
+ CLOCKS_PER_SEC > 0
145
+ ? (Duration::period::den / CLOCKS_PER_SEC / Duration::period::num)
146
+ : 0 ;
145
147
146
148
Duration cDuration ((cEnd - cStart) * clockMultiply);
147
149
return {std::chrono::duration_cast<Duration>(tEnd - tStart),
@@ -177,14 +179,16 @@ perform(const SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> &buffers,
177
179
std::chrono::duration_cast<std::chrono::milliseconds>(tDuration).count ();
178
180
auto cDisplay =
179
181
std::chrono::duration_cast<std::chrono::milliseconds>(cDuration).count ();
182
+ llvm::outs () << llvm::format (" wall clock time (ms): %8d\n " , tDisplay)
183
+ << llvm::format (" cpu time (ms): %8d\n " , cDisplay);
180
184
181
- auto byteTPS = totalBytes * duration_t ::period::den / cDuration.count ();
182
- auto lineTPS = totalLines * duration_t ::period::den / cDuration.count ();
185
+ if (cDuration.count () > 0 ) {
186
+ auto byteTPS = totalBytes * duration_t ::period::den / cDuration.count ();
187
+ auto lineTPS = totalLines * duration_t ::period::den / cDuration.count ();
183
188
184
- llvm::outs () << llvm::format (" wall clock time (ms): %8d\n " , tDisplay)
185
- << llvm::format (" cpu time (ms): %8d\n " , cDisplay)
186
- << llvm::format (" throughput (byte/s): %8d\n " , byteTPS)
187
- << llvm::format (" throughput (line/s): %8d\n " , lineTPS);
189
+ llvm::outs () << llvm::format (" throughput (byte/s): %8d\n " , byteTPS)
190
+ << llvm::format (" throughput (line/s): %8d\n " , lineTPS);
191
+ }
188
192
}
189
193
190
194
} // namespace
0 commit comments