Stack Exchange

QotW: Does running Commands in Verbose Mode slow them down?

August 1, 2011 by . 3 comments

This week’s Question of the Week comes from MaxMaxie, and is about command line usage in Linux:

Does running commands verbosely make them slower?

I’ve found myself using the -v flag for lots of applications less and less (especially for trivial stuff liketar and cp). However, when I did and I was, say, unzipping a large file, it would take longer than when I didn’t use the -v flag. I assume this is because the terminal has to process the text and I’m filling up whatever buffer it might have. But my question is, does this make the application actually run slower or does it complete in the same amount of time and what I’m seeing is the terminal trying to catch up?

According to Matt Jenkins, it does indeed. His explanation of why is an interesting read, but the question remains: exactly how much does it slow things down? I decided to find out – read on to see just how much of a difference verbose flags can make.

I wanted to test this on something with a mix of file sizes, so I chose the latest download of WordPress, unzipped it, and performed verbose and normal copy operations on the extracted file in Windows 7 and Ubuntu 11.04. The results confirmed what Matt Jenkins told us for Linux, but Windows shows a different story.

Windows 7: xcopy command

The xcopy command is used on Windows for copying directories of data. There is no timer command built into the Windows command prompt, so I made a rudimentary one which echos the time when the command starts to run and the time when the command is done running. Below are the times for copying with the default option, which is verbose, and the /Q switch, which runs the copy silently:

Interestingly, the speed was not always consistent: 2/3 times I ran it, the command was slower when using the default verbose options than it was when running with the quiet output flag. This may have to do with the program being designed to run with the extra info: it may take more processing time to generate that output, and then not show it, than it does to generate and show it.

Ubuntu 11.04: cp command

The results for Linux are much more noticeable: the verbose command (with the -v flag) is slower every time, sometimes by as much as 75%.



It appears that running Linux commands in verbose mode does have a significant affect on the speed of the execution. In Windows, the difference is less well-defined. These were just some quick tests, and more benchmarks would be necessary to figure out how much of a difference occurs in what situations, but it seems like at least for Linux, the basic advice is true: in the future, if you’re looking for speed and don’t need that extra info, leave off that -v, and you might get done a bit quicker!


Subscribe to comments with RSS.

  • Richard says:

    There is no timer command built into the Windows command prompt

    There is: Measure-Command. Inbuilt into PowerShell.

    Of course, if you want to stick with cmd.exe, then expect all cmd.exe’s limitations.

  • forammor says:

    While the windows timings are in the seconds range, the linux timings are an order of magnitude lower! Although the measurements appear consistent, I doubt that the linux timings are very accurate.

  • Christopher Allen-Poole says:

    The difference in scales is deceptive. While the differences between quiet and verbose may be substantial in terms of a raw percentage, in terms of time spent, this is a trivial difference.

  • Leave a comment

    Log in
    with Stack Exchange