time

Discussion in 'Linux / Unix Discussion' started by ffreeloader, Nov 22, 2005.

  1. ffreeloader

    ffreeloader Terabyte Poster

    3,661
    106
    167
    Just thought I'd put this up here as a little bit of interesting trivia.

    One of the commands available from the bash prompt is "time". What follows is one of it's interesting usages. If you enter the following syntax "time" will tell you how long command or a group of pipelined commands takes to execute on your machine: time command1 | command2. It will tell you how long it took to execute the commands in three different ways.

    First it will tell you how long it took for the entire command to execute from start to finish. Say you enter the following command: ls -R /usr. This command will print to the screen, recursively, every file and directory in the /usr directory. It will do so by first listing the subdirectories and file in /usr. Then it will start in on each subdirectory and recursively list out the contents of each down through all levels of subdirectories. As you can imagine this takes quite a while if /usr holds 3 gB's of data because the system must print to screen everything in that 3 gB's of data.

    Second, it will tell you how long the system took in the total number of CPU-seconds used by the system on behalf of the process (in kernel mode), in seconds.

    Third, it will tell you how long the system took in the total number of CPU-seconds that the process used directly (in user mode), in seconds.

    For example, I ran "time ls -R /usr" on two of my systems. One took 2 minutes and 45.683 seconds of real time to complete. It also used 2.477 seconds of "user" time and 3.392 seconds of "system" time. This system has 3.03 gB's of data in /usr. Another system took 58.269 seconds of "real" time, .910 seconds of "user" time, and .697 seconds of "system" time. This system has 1004 mB's of data in /usr.

    Interestingly enough the first system is much faster as far as cpu clock speed, graphics engine capabilities, graphics card memory, and has more ram. The main differences in the disks are that I set up the disks on the slower system using lvm2 with /usr, /var, /home, and / being on separate partitions, and the faster system was installed on a single "basic" partition.

    Anyway, I thought this was a rather handy little tool. It can also be used with bash scripts to see how many total cpu seconds are used to run the scripts you use. The syntax is pretty much the same: "time script_name.sh(include any parameters necessary for script execution)".
     
    Certifications: MCSE, MCDBA, CCNA, A+
    WIP: LPIC 1
  2. Boycie
    Honorary Member

    Boycie Senior Beer Tester

    6,281
    85
    174
    another good command ,cheers Freddie :thumbleft
     
    Certifications: MCSA 2003, MCDST, A+, N+, CTT+, MCT

Share This Page

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.