2015-08-12 3 views
0

Dans un rapport de bogue de GCC (Bug 51617), les temps d'affichage de son asynchrone (11 C++) l'exécution de programme avec une sortie qui ressemble à ceci:Mesure l'utilisation du processeur du programme multithread

/tmp/tst 81.54s user 0.23s system 628% cpu 13.001 total 

Qu'est-ce que l'affiche pourrait être utilisant qui donne cette sortie (ou similaire)? NB: Une inspection de mon entrée pour time ne suggère rien d'utile à cette fin.

+0

Souvent, 'time' est une coquille builtin –

+0

@BasileStarynkevitch est vrai --- il n'y a pas un binaire associé à celui-ci sur mon système, donc j'ai supposé que cela faisait partie de ma mise en œuvre de BASH. Je suis inquiet que j'ai créé une distraction en incluant 'time' dans la question. Je veux juste juste savoir ce qui pourrait produire la sortie du rapport de bogue. – Timtro

Répondre

2

Le temps (1) page de manuel sur mon système Linux (Ubuntu) dit:

-f FORMAT, --format FORMAT 
      Use FORMAT as the format string that controls the output of 
      time. See the below more information. 

:

FORMATTING THE OUTPUT 
    The format string FORMAT controls the contents of the time output. The 
    format string can be set using the `-f' or `--format', `-v' or `--ver‐ 
    bose', or `-p' or `--portability' options. If they are not given, but 
    the TIME environment variable is set, its value is used as the format 
    string. Otherwise, a built-in default format is used. The default 
    format is: 
    %Uuser %Ssystem %Eelapsed %PCPU (%Xtext+%Ddata %Mmax)k 
    %Iinputs+%Ooutputs (%Fmajor+%Rminor)pagefaults %Wswaps 

:

The resource specifiers, which are a superset of those recognized by 
    the tcsh(1) builtin `time' command, are: 
      %  A literal `%'. 
      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 oc‐ 
       curred while the process was running. These are faults 
       where the page has actually migrated out of primary memo‐ 
       ry. 
      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 life‐ 
       time, 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 direct‐ 
       ly (in user mode), in seconds. 
      W  Number of times the process was swapped out of main memo‐ 
       ry. 
      X  Average amount of shared text in the process, in Kilo‐ 
       bytes. 
      Z  System's page size, in bytes. This is a per-system con‐ 
       stant, but varies between systems. 
      c  Number of times the process was context-switched involun‐ 
       tarily (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 opera‐ 
       tion to complete. 
      x  Exit status of the command. 

vous pouvez donc obtenir le pourcentage de CPU %P dans le format.

Notez que ceci est pour le /usr/bin/time binaire - la coquille time est généralement différente builtin (et moins capable)

+0

J'ai dû installer la version binaire de 'time'. Vous avez raison, ils sont assez différents --- celui construit dans BASH n'implémente même pas l'option -v. La ligne de commande que j'ai créée pour imiter celle ci-dessus est '/ usr/bin/time -f"% C% Us utilisateur% Ss système% P CPU% Es total exit% x "' – Timtro