Time (vana): Difference between revisions

From ICO wiki
Jump to navigationJump to search
Line 79: Line 79:
Ülejäänud tekst kuvatakse nii, nagu see on format stingis antud. [3]
Ülejäänud tekst kuvatakse nii, nagu see on format stingis antud. [3]


Siinkohal on toodud väljavõte time manuaalis ('''man time''') toodud karakteritest:
              C      Name and command line arguments of the command being
                    timed.
              D      Average size of the process's unshared data area, in
                    Kilobytes.
              E      Elapsed real (wall clock) time used by the process, in
                    [hours:]minutes:seconds.
              F      Number of major, or I/O-requiring, page faults that
                    occurred while the process was running.  These are faults
                    where the page has actually migrated out of primary
                    memory.
              I      Number of file system inputs by the process.
              K      Average total (data+stack+text) memory use of the
                    process, in Kilobytes.
              M      Maximum resident set size of the process during its
                    lifetime, in Kilobytes.
              O      Number of file system outputs by the process.
              P      Percentage of the CPU that this job got.  This is just
                    user + system times divided by the total running time.
                    It also prints a percentage sign.
              R      Number of minor, or recoverable, page faults.  These are
                    pages that are not valid (so they fault) but which have
                    not yet been claimed by other virtual pages.  Thus the
                    data in the page is still valid but the system tables
                    must be updated.
              S      Total number of CPU-seconds used by the system on behalf
                    of the process (in kernel mode), in seconds.
              U      Total number of CPU-seconds that the process used
                    directly (in user mode), in seconds.
              W      Number of times the process was swapped out of main
                    memory.
              X      Average amount of shared text in the process, in
                    Kilobytes.
              Z      System's page size, in bytes.  This is a per-system
                    constant, but varies between systems.
              c      Number of times the process was context-switched
                    involuntarily (because the time slice expired).
              e      Elapsed real (wall clock) time used by the process, in
                    seconds.
              k      Number of signals delivered to the process.
              p      Average unshared stack size of the process, in Kilobytes.
              r      Number of socket messages received by the process.
              s      Number of socket messages sent by the process.
              t      Average resident set size of the process, in Kilobytes.
              w      Number of times that the program was context-switched
                    voluntarily, for instance while waiting for an I/O
                    operation to complete.
              x      Exit status of the command.


Default format:
Default format:
Line 94: Line 144:
  Wed Dec 12 18:06:31 EET 2012
  Wed Dec 12 18:06:31 EET 2012
         0.00 user,      0.00 system,    0 status
         0.00 user,      0.00 system,    0 status
{|class="wikitable"
|
! Parameeter
! Kirjeldus
! width="150"| Väärtus/Näide
|-
|-
| '''%a''' ||a  || a
|}


=Kasutatud kirjandus=
=Kasutatud kirjandus=

Revision as of 18:32, 12 December 2012

Autor

Karmen Matkur AK41


Sissejuhatus

time käsuga saame teada ajalist statistikat, mis on seotud etteantud käskluse täideviimisega. [1] Time käsk on bash shell’i sisseehitatud käsklus, mille tulemusel väljastatakse etteantud käskluse täitmiseks kulunud reaalne aeg, kasutaja CPU aeg ja süsteemi CPU aeg.

Kasutades /usr/bin/time käsku, saame lisaks eelmainitud ajalisele tastistikale soovi korral näha veel andmeid mälu, I/O jne kohta.

Näited on toodud kasutades Ubuntu Server 12.10 versiooni.


Time

Süntaks

time [võtmed] käsklus [argumendid...] [2]

Võtmed

-p - Võimaldab määrata väljundi formaati, mis on vastavuses POSIX'ga. Soovitatakse kasutada "real %f\nuser %f\nsys %f\n" formaati, kus tulemus teisaldatakse sekunditeks, kümnendike koht pole täpsustatud, kuid on piisavalt täpne ning vähemalt 1 koht peale koma. [2]

help time: kuvatakse käskluse time kasutamise juhend.

Kirjeldus

Time käsuga täidetakse soovitud käsklus etteantud argumentidega ning seejärel väljastatakse käskluse täitmisele kulunud ajaline statistika.

Väljastatakse kolm aega:

  • Reaalne aeg, mis jäi käskluse esilekutsumise ja täitmise vahele.
  • Kasutaja CPU aeg (sekundites), mis kulutati käskluse täitmiseks.
  • Süsteemi CPU aeg (sekundites), mis kulutati käskluse täitmiseks.


Näide

$ time ls

Tulemus:

kala.txt  nimekiri.txt

real    0m0.005s
user    0m0.000s
sys     0m0.004s

/usr/bin/time

Süntaks

/usr/bin/time [võtmed] käsklus [argumendid...] [3]


Võtmed

  • -v, –verbose: kasutatakse siis, kui soovitakse detailsemat kirjeldust väljundile.
  • –quite : välditakse programmi staatuse raporteerimist väljundis. [3]
  • -f, –format : kasutaja saab määrata väljundi infot ja vormi.
  • -p - Võimaldab määrata väljundi formaati, mis on vastavuses POSIX-ga
  • -o FILE: suunatakse time väljund faili,
  • –output=FILE: suunatakse time väljund faili, kus vana sisu kirjutatakse üle
  • -a, –append: kirjtuatakse väljund faili lõppu, välditakse ülekirjtamist. [3]
  • --help : kuvatakse kasutamise juhend
  • -V, --version: kuvatakse versiooni informatsioon [2]

man time – kuvatakse manual /usr/bin/time kasutamise kohta


- format

Siin lubatakse kasutajal otsustada, millist informasiooni ja millisel kujul väljastatakse.

Format string sisaldab:

  • % + karakter: määratakse, milliseid andmeid näidatakse
  • \: määratakse vorm, kuidas tulemus väljastatakse:

*\t: tabeli vorm *\n: järgnev tulemus kuvatakse uuele reale *\\: kuvatakse \ Ülejäänud tekst kuvatakse nii, nagu see on format stingis antud. [3]


Siinkohal on toodud väljavõte time manuaalis (man time) toodud karakteritest:

             C      Name and command line arguments of the command being
                    timed.
             D      Average size of the process's unshared data area, in
                    Kilobytes.
             E      Elapsed real (wall clock) time used by the process, in
                    [hours:]minutes:seconds.
             F      Number of major, or I/O-requiring, page faults that
                    occurred while the process was running.  These are faults
                    where the page has actually migrated out of primary
                    memory.
             I      Number of file system inputs by the process.
             K      Average total (data+stack+text) memory use of the
                    process, in Kilobytes.
             M      Maximum resident set size of the process during its
                    lifetime, in Kilobytes.
             O      Number of file system outputs by the process.
             P      Percentage of the CPU that this job got.  This is just
                    user + system times divided by the total running time.
                    It also prints a percentage sign.
             R      Number of minor, or recoverable, page faults.  These are
                    pages that are not valid (so they fault) but which have
                    not yet been claimed by other virtual pages.  Thus the
                    data in the page is still valid but the system tables
                    must be updated.
             S      Total number of CPU-seconds used by the system on behalf
                    of the process (in kernel mode), in seconds.
             U      Total number of CPU-seconds that the process used
                    directly (in user mode), in seconds.
             W      Number of times the process was swapped out of main
                    memory.
             X      Average amount of shared text in the process, in
                    Kilobytes.
             Z      System's page size, in bytes.  This is a per-system
                    constant, but varies between systems.
             c      Number of times the process was context-switched
                    involuntarily (because the time slice expired).
             e      Elapsed real (wall clock) time used by the process, in
                    seconds.
             k      Number of signals delivered to the process.
             p      Average unshared stack size of the process, in Kilobytes.
             r      Number of socket messages received by the process.
             s      Number of socket messages sent by the process.
             t      Average resident set size of the process, in Kilobytes.
             w      Number of times that the program was context-switched
                    voluntarily, for instance while waiting for an I/O
                    operation to complete.
             x      Exit status of the command.

Default format:

%Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k 
%Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps


Näide:

$ /usr/bin/time -f "\t%U user,\t%S system,\t%x status" date

Tulemus:

Wed Dec 12 18:06:31 EET 2012
       0.00 user,      0.00 system,    0 status

Kasutatud kirjandus

1. http://en.wikipedia.org/wiki/Time_(Unix)

2. http://linux.about.com/library/cmd/blcmdl1_time.htm

3. http://www.thegeekstuff.com/2012/01/time-command-examples/