@@ -141,7 +141,9 @@ static std::pair<Duration, Duration> measure(llvm::function_ref<void()> body) {
141141 auto tEnd = std::chrono::steady_clock::now ();
142142
143143 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 ;
145147
146148 Duration cDuration ((cEnd - cStart) * clockMultiply);
147149 return {std::chrono::duration_cast<Duration>(tEnd - tStart),
@@ -177,14 +179,16 @@ perform(const SmallVectorImpl<std::unique_ptr<llvm::MemoryBuffer>> &buffers,
177179 std::chrono::duration_cast<std::chrono::milliseconds>(tDuration).count ();
178180 auto cDisplay =
179181 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);
180184
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 ();
183188
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+ }
188192}
189193
190194} // namespace
0 commit comments