1. 学ぶ
  2. /
  3. コース
  4. /
  5. Optimizing Code in Java

Connected

演習

Analyzing CPU time

You're optimizing a financial analysis application that performs calculations. To get a precise understanding of processor usage, you need to implement a utility that measures the exact CPU time consumed by different operations, which will help you identify which calculations are truly CPU-intensive.

The necessary lang.management packages have been imported for you.

指示

100 XP
  • Retrieve the ThreadMXBean instance from the ManagementFactory class.
  • Get the CPU time for the current thread.