Qual é a unidade de tempo que a strace usa ao exibir o tempo gasto em syscalls?

9

Ao usar o comando strace com o sinalizador -T , gostaria de saber qual é a unidade de tempo usada para exibir o tempo gasto em syscalls? Eu suponho que deveria ser em segundos, mas não tenho certeza e parece ser omitido do manual.

    
por user311285 17.09.2018 / 15:25

3 respostas

22

De o código-fonte :

if (Tflag) {
    ts_sub(ts, ts, &tcp->etime);
    tprintf(" <%ld.%06ld>",
        (long) ts->tv_sec, (long) ts->tv_nsec / 1000);
}

Isso significa que o tempo é mostrado em segundos, com microssegundos (calculados a partir do valor de nanossegundos) após o ponto decimal.

    
por 17.09.2018 / 15:33
13

Se você correr

strace -T  sleep 2

você verá

nanosleep({tv_sec=2, tv_nsec=0}, NULL)  = 0 <2.000230>

, então parece que o tempo gasto é em segundos.

    
por 17.09.2018 / 15:32
6

Se você executar o comando strace usando a "flag -c", ele mostrará uma tabela e a hora será informada em segundos :

strace -c -p 3569 # 3569 is PID
strace: Process 3569 attached
^Cstrace: Process 3569 detached
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
99.73    0.016000           8      1971           poll
0.16    0.000025           0       509        75 futex
0.06    0.000010           0      1985      1966 recvmsg
0.06    0.000009           0      2336           mprotect
0.00    0.000000           0       478           read
0.00    0.000000           0        13           write
0.00    0.000000           0        29           mmap
0.00    0.000000           0         9           munmap
0.00    0.000000           0        18           writev
0.00    0.000000           0       351           madvise
0.00    0.000000           0         1           restart_syscall
------ ----------- ----------- --------- --------- ----------------
100.00    0.016044                  7700      2041 total

do homem de strace

-c

Count time, calls, and errors for each system call and report a summary on program exit. On Linux, this attempts to show system time (CPU time spent running in the kernel) independent of wall clock time. If -c is used with -f or -F (below), only aggregate totals for all traced processes are kept.

    
por 17.09.2018 / 15:39
yii\base\ErrorException
Copied! Copy Stacktrace Search Stackoverflow Search Google Error

PHP Core Warning – yii\base\ErrorException

PHP Startup: Unable to load dynamic library 'memcached.so' (tried: /usr/lib/php/20190902/memcached.so (/usr/lib/php/20190902/memcached.so: undefined symbol: igbinary_serialize), /usr/lib/php/20190902/memcached.so.so (/usr/lib/php/20190902/memcached.so.so: cannot open shared object file: No such file or directory))

$_GET = [
    'id' => '778853',
    'url' => 'what-is-the-time-unit-that-strace-uses-when-displaying-time-spent-in-syscalls',
];

$_COOKIE = [
    'advanced-frontend' => '5c1qtkivmbk5ef26qkgcdf6l0m',
    '_csrf-frontend' => 'd7b75c08e3f940dcdfc0d81e7f846c62b39c51c2140b6a9ed8658b1acd0b33bea:2:{i:0;s:14:"_csrf-frontend";i:1;s:32:"VUwiPjGMPa5RmIoqC3iX9h7z0GoAbonc";}',
];

$_SESSION = [
    '__flash' => [],
];