Time (vana): Difference between revisions

From ICO wiki
Jump to navigationJump to search
Kkattai (talk | contribs)
Kkattai (talk | contribs)
Line 74: Line 74:
*% + karakter: määratakse, milliseid andmeid näidatakse
*% + karakter: määratakse, milliseid andmeid näidatakse
*\: määratakse vorm, kuidas tulemus väljastatakse:
*\: määratakse vorm, kuidas tulemus väljastatakse:
*\t: tabeli vorm
\t: tabeli vorm
*\n: järgnev tulemus kuvatakse uuele reale
\n: järgnev tulemus kuvatakse uuele reale
*\\: kuvatakse \
\\: kuvatakse \
 
Ülejäänud tekst kuvatakse nii, nagu see on format stingis antud. [3]
Ülejäänud tekst kuvatakse nii, nagu see on format stingis antud. [3]


Line 82: Line 83:
Siinkohal on toodud väljavõte time manuaalis ('''man time''') toodud karakteritest:
Siinkohal on toodud väljavõte time manuaalis ('''man time''') toodud karakteritest:


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


Default format:
Default format:

Revision as of 18:36, 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/