When you’reterminal command line is busy, it can be difficult to time a specific action. This article will teach you how to time a terminal command in a more efficient way. To time a terminal command, use the following steps:

  1. Type the command you want to time in the terminal. For example, if you want to time the length of a file, type “ls”.
  2. The Terminal will print out the time it takes for the command to complete. For example, if ls took 10 seconds to complete, the Terminal would print “10 seconds.”
  3. To stop the timer after it has completed its task, use “cancel” or “x”.

If you have a long running script that you are working on improving, it can be useful to figure out exactly how long the script or command takes to run so you’ll know for sure whether the next run was faster or slower than the first one.

Luckily there’s an easy way to do it using the time command. Simply start with time, and then whatever command you want to run.

You’ll see the output something like this:

And just in case you don’t understand the arcane output, the 3 different values mean these things:

Real: The actual time from start to finish, which could vary if other things are using up the CPU. This is generally the number you’ll care about unless you’re testing on a really busy system. User: The time the command took from start to finish running user mode code. Sys: The execution time for system calls in the kernel by the process. It’s fairly meaningless for most people by itself.

You can use the combination of User + Sys to actually figure out exactly how long your command took for timing purposes…. but if you’re on a test box, Real is simpler.