- System requirements
- Profiler architecture
- Profiler installation
- Uninstall profiler
- Running the profiler
- Profiler activation
- Welcome screen
- Start profiling
- Profiling overhead
- Snapshots
- Solving performance problems
- CPU profiling
- Thread profiling
- Virtual threads support
- Object allocation profiling
- Memory profiling
- Monitor profiling
- Exception profiling
- Telemetry
- Probes: monitor events of various kinds
- Inspections: automatic recognition of typical problems
- Automatically trigger actions on event
- Automatic deobfuscation
- Summary
- Filters
- Profiler command line
- Export of profiling results to external formats
- Profiler Java API
- Profiler HTTP API
- Settings
- Troubleshooting and FAQ
Wall and CPU times when profiling Java applications
When profiling Java applications, it's essential to understand the concepts of CPU time and wall time to make informed decisions about application performance optimization. These two metrics represent different aspects of the time taken by your Java application during execution, and each can provide valuable insights depending on your specific use case.
CPU time
CPU time, also known as process time, refers to the amount of time the CPU spends actively executing instructions for a specific process or thread. This metric only considers the time during which a CPU is working on behalf of the process, excluding any time spent waiting for external resources, input/output operations, or other processes.
Usage: CPU time is particularly useful for identifying computationally intensive parts of your Java application. By focusing on the sections of your code that consume the most CPU time, you can pinpoint areas where optimization may lead to improved overall performance.
Wall time
Wall time, also known as real time or elapsed time, is the total time taken from the start to the completion of a process or operation, as measured by a regular clock. Wall time includes all time intervals, including waiting for resources, input/output operations, or other processes, as well as active execution time.
Usage: Wall time is valuable for understanding the actual user-perceived execution time of your Java application or specific parts of it. Profiling using wall time can help identify bottlenecks due to resource contention, slow I/O, or other non-computation-related delays that impact the overall responsiveness of your application.
Differences between CPU time and wall time
The main difference between CPU time and wall time lies in what they measure. CPU time focuses on the active computation time of the CPU, excluding any waiting periods. In contrast, wall time considers the entire duration of a process or operation, including both active execution and waiting times.
As a result, CPU time can be shorter than wall time, especially in multi-threaded or multi-process applications where processes might be waiting for resources, I/O, or other processes to complete.
When to use CPU time vs. wall time
Use CPU time when
- Profiling computationally intensive parts of your Java application.
- Identifying functions or methods that consume excessive CPU cycles.
- Diagnosing performance issues related to algorithmic complexity, inefficient data structures, or other code-level optimizations.
Use wall time when
- Profiling the overall user-perceived execution time of your Java application.
- Identifying bottlenecks due to resource contention, slow I/O operations, or other external factors.
- Understanding the impact of waiting times on your application's responsiveness.
CPU and wall times in YourKit Java Profiler
YourKit Java Profiler has reasonable default settings, as well as a flexible system for configuring wall time and CPU time for all profiling modes:
CPU profiling
1. Asynchronous CPU sampling by its nature always measures CPU time.
2. Classic synchronous CPU sampling and asynchronous periodic CPU sampling measure CPU time by default, but they can be configured to measure wall time.
3. CPU tracing measures wall time by default, and can be configured to measure CPU time instead.
You can choose between CPU and wall time measurement in CPU sampling settings and CPU tracing settings.
Monitor profiling
Monitor profiling measures wall time for all waiting and blocking methods.