Section 5.14 of CS:APP3e demonstrates how to use the code profiling tool gprof to identify slow portions of a program. It uses as an example a dictionary program that can compute n-gram statistics about a body of text. Here's the measurements from profiling the code when computing the bigram statistics of all of Shakespeare's works:
We have made all of the code used in this example available on the CSAPP student website, as part of the Chapter 5 materials. The code has been tested on multiple Linux systems. You can see how to code does when running on your machine.