-
Book Overview & Buying
-
Table Of Contents
LLVM Techniques, Tips, and Best Practices Clang and Middle-End Libraries
By :
LLVM is an enormous software, with hundreds of components working closely together. Its ever-increasing running time is slowly becoming an issue. This affects many use cases that are sensitive to compilation time—for example, the Just-in-Time (JIT) compiler. To diagnose this problem in a systematic way, LLVM provides some useful utilities for profiling the execution time.
Time profiling has always been an important topic in software development. With the running time collected from individual software components, we can spot performance bottlenecks more easily. In this section, we are going to learn about two tools provided by LLVM: the Timer class and the TimeTraceScope class. Let's start with the Timer class first.
The Timer class, as suggested by its name, can measure the execution time of a code region. Here is an example of this:
#include "llvm/Support/Timer.h"
…
Timer T("MyTimer"...