liveBook · Manning

CPU time

As explained in Troubleshooting Java, Second Edition

CPU time is the amount of processor time a method or operation actively spends executing instructions.

CPU time measures how long a method actively uses the processor to execute instructions. Compare it with total execution time when investigating latency. section 6.1

Use CPU time to guide performance diagnosis:

  • High CPU time indicates that the method is doing work; reducing algorithmic complexity may improve performance. section 6.1
  • Low CPU time combined with long execution time indicates waiting, such as for an HTTP response. section 6.1
  • Profiler stacks include application methods and dependency methods, helping locate work or waiting across the call path. section 6.1

Five-second HTTP delay

A /demo endpoint takes about five seconds because getResponseCode() waits for an HTTP response. Its CPU time is zero, so the application is waiting rather than consuming processor resources. section 6.1

How Troubleshooting Java, Second Edition covers it

How deep it goes
Explains the metric through profiler observations and contrasts it with execution time, stopping short of measurement internals.
Examples
Uses a five-second /demo HTTP delay where getResponseCode() spends execution time waiting with zero CPU time.
What it assumes
Assumes basic method execution knowledge while defining CPU time and profiler observations directly.
What you can do after
Diagnose latency by comparing CPU time with execution time in profiler stacks.
How it connects
Connects CPU time with execution time, latency, profiling, stack traces, HTTP requests, and algorithmic complexity.

Also explained in

Compare how 4 books explain CPU time →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Troubleshooting Java, Second Edition. The section links point to the parts of the book it draws on.