Cpu Time Vs Wall Time 2021 Which Is Better And Why

Cpu Time Vs Wall Time 2022: Which Is Better And Why?

Your process might be slow because it is very CPU-intensive. Or maybe it’s blocking I/O (network, filesystem) or locks. How can you tell?

Your process will only get small task slices between processing requests. Each task slice is added to the total execution time. The CPU time spent processing other requests is not included in your total execution time.

There are many answers. In this article, Medcpu will focus on comparing Cpu Time Vs Wall Time.

Wall clock time vs CPU time

The CPU time is not the same as wall time (as in, a clock on the wall). CPU time refers to the total execution time of a process.

Wall clock time vs CPU time

Your process will only get small task slices between processing requests. Each task slice is added to the total execution time. The CPU time spent processing other requests is not included in your total execution time.

Let’s take, for example, gzip on 20MB Apache log files to see how long it took.

  • $ time gzip access.log
  • Real 0m2.125s
  • User 0m1.920s
  • sys 0.1770s

The process took 2.125 seconds of wall time (“real”) and 1.920 seconds of CPU time (“user”), while 0.170 seconds was spent in kernel mode (“sys”). The time spent on other processes was 0.035 seconds. (Remember that compressing files is a very intensive task that consumes a lot of CPU time on the server.

Some processes take a lot of CPU time but require little wall time. The next example illustrates the processing time required to run ‘find’ on the HC01 server’s /big/dom trees.

  • $ time find /big/dom -ls
  • Real 0m37.707s
  • User 0m1.210s
  • sys 0m1.260s

This task has a large difference between CPU and wall time. It took 35.237 seconds to complete the task. The time was sliced for other processes.

Because it takes over 50,000 files for the screen to print, the Linux Kernel’s scheduling system was free to allow other processes to have more time slices. This is because of the extra processing overhead required to print text to a screen using the print function.

This example will eliminate the delay in displaying the file list on the screen.

  • $ time find /big/dom -ls > /dev/null
  • Real 0m1.164s
  • User 0m0.900s
  • sys 0.260s

There is now a difference in time between the CPU time and wall time of 0.004 seconds.

Read also:

13 Vs 15 Inch Laptop 2022: Which Is Better And Why?

24 Vs 27 Monitor 2022: Which Is Better And Why?

How To Use Laptop As Monitor For Ps4

What you can learn from different ratios

The CPU clock time was less than the wall clock time in the above example, but there are other possible relationships. It is easier to express the potential relationship as a ratio (CPU time / (wallclock time), CPU/second.

What you can learn from different ratios

If this is a single-threaded process:

  • CPU/second 1: The CPU was used by the entire process. The program will run faster if it has a faster CPU.
  • CPU/second 1. The smaller the number, the longer the process takes to wait (for the network or harddrive or locks or any other processes to release the CPU or just sleeping). For example, If CPU/second was 0.75, 25% time was spent waiting.

This can be a multi-threaded task if your computer has at least N CPUs and N threads. In this case, CPU/second could be as high N.

  • CPU/second = 1: The process spent a lot of time waiting.
  • CPU/second N: All CPUs were saturated.

Other values: This process involved some combination of CPU and waiting. It can be difficult to determine which bottleneck is with this measurement alone. The number of threads can be used to help you determine if you are saturated. If you have 2 threads running and the CPU/second is 2, then you are saturated.

CPU usage over time with the psutil Python library

We’ve only been looking at CPU usage over the entire process, but it is possible to measure it over time. The psutil library in python timer makes it easy to measure CPU usage over time. It provides a lot of useful information about processes.


There you have it – the comparison between wall time vs CPU time. There is no cut-and-dried rule for how the CPU time for a process will be sliced as it mostly depends on the processing requirements of the task and how many other processes are vying for the CPU’s attention. Please leave a comment below if this article helped you.

Eyal Ephrat

Eyal Ephrat, M.D., the co-founder and CEO of healthPrecision, has a proven track record as an entrepreneur capable of bringing genuinely innovative and successful solutions to market. A technologist, Dr. Ephrat is considered one of the industry’s leaders in paving the path for clinicians’ successful adoption of computerized assistance and automation. His work brings high-precision and reliable intelligent decision solutions to the point of care, solving what was once one of the most persistent barriers to computer use by clinicians. Dr. Ephrat previously co-founded medCPU and served as its CEO. During his tenure, medCPU was in use by more than 60 hospitals and hospital systems across the United States and was considered one of the best real-time, intelligent clinical decision support solutions available. Before medCPU, Dr. Ephrat founded and served as CEO of PeriGen, a pioneer in high-precision point-of-care clinical decision support in obstetrics. Under his leadership, the solution was deployed in more than 40 hospitals and health systems. PeriGen has been highly respected by its long-term users since 2000. Dr. Ephrat earned his Doctor of Medicine degree from The Hebrew University-Hadassah Medical School in Jerusalem and served as a resident OB/GYN physician at Sha'are Zedek Medical Center, where he concentrated mainly in high-risk obstetrics. Before attending medical school, Dr. Ephrat served as Chief Designer and Developer at Advanced Communications and Logical Systems.

View all posts by Eyal Ephrat

Leave a Comment

Your email address will not be published. Required fields are marked *