Save this as sc.d:

--------------------------- sc.d ---------------------------
#!/usr/sbin/dtrace -qs

syscall:::entry
/pid == $target/
{
        @count[probefunc] = count();
        self->st[probefunc] = timestamp;
}
syscall:::return
/self->st[probefunc]/
{
        this->t = (timestamp - self->st[probefunc]) / 1000;
        @times[probefunc] = sum(this->t);

        self->st[probefunc] = 0; this->t = 0;
}
END
{
        printf("%-16s %-8s %-8s\n","SYSCALL","COUNT","TIME(us)");
        printa("%-16s %-@8d %-@8d\n",@count,@times);
}
--------------------------------------------------------------------------------------

Run as:
#./sc.d -p [PID_OF_TARGET_PROCESS]

You'll get something like this when you ^c to terminate:

^C
SYSCALL          COUNT    TIME(us)
chdir            3        21
faccessat        4        13
forksys          6        1855
waitsys          6        14956
fstatat64        7        67
gtime            18       26
setpgrp          29       61
read             51       13289380
write            60       1037
ioctl            97       701
sigaction        216      358
lwp_sigmask      232      443

Sorry about the formatting - I can't seem to get a fixed-width font to work
in
$%$^&#$%$@#$ gmail.

Anyway, the Time is in microseconds, and represents the total amount
of wall clock time during the collection period for each system call.

A lot more is of course possible.

Jim




On Wed, Mar 5, 2014 at 12:53 PM, Mahmood Naderan <nt_mahm...@yahoo.com>wrote:

> Ok I found 'truss' command to be useful for my problem.
> Just one question, hope that somebody knows the answer. I know that this
> list is not directly related to DTrace list.
>
> I used 'truss -c -p 1010' and the output is
>
> syscall               seconds   calls  errors
> write                    .005      77
> close                    .000       1
> brk                      .000       8
> lwp_park                 .407    6631
> lwp_unpark               .246    5832
> sysconfig                .000       1
> yield                    .012     212
> llseek                   .000       1
> lwp_mutex_timedlock      .000       1
> open64                   .000       2
>                      --------  ------   ----
> sys totals:              .672   12766      0
> usr time:             310.172
> elapsed:               33.990
>
>
> I see that elapsed time is less that (sys+user).
> Does anybody know the reason?
>
> Regards,
> Mahmood
>
>
> On Sunday, March 2, 2014 12:08 PM, Mahmood Naderan <nt_mahm...@yahoo.com>
> wrote:
> Hi,
> How can I find the execution time of each syscall using DTrace (or any
> other developers related tool)?
> For example, I can see
>
> fstat     100
> sendto  400
> brk  50
>
> I want to know which one has the largest overhead in the run time.
> 100 * (execution of one fstat)
> or
> 400 * (execution of one sendto)
> or
> 50 * (execution of one brk)
>
> Any feedback is appreciated.
>
> Regards,
> Mahmood
> *dtrace-discuss* | 
> Archives<https://www.listbox.com/member/archive/184261/=now>
> <https://www.listbox.com/member/archive/rss/184261/24744495-1acb86e1> |
> Modify <https://www.listbox.com/member/?&;> Your Subscription
> <http://www.listbox.com/>
>
>
> *dtrace-discuss* | 
> Archives<https://www.listbox.com/member/archive/184261/=now>
> <https://www.listbox.com/member/archive/rss/184261/21493819-f797b643> |
> Modify<https://www.listbox.com/member/?&;>Your Subscription
> <http://www.listbox.com>
>



-------------------------------------------
dtrace-discuss
Archives: https://www.listbox.com/member/archive/184261/=now
RSS Feed: https://www.listbox.com/member/archive/rss/184261/25769126-e243886f
Modify Your Subscription: 
https://www.listbox.com/member/?member_id=25769126&id_secret=25769126-8d47a7b2
Powered by Listbox: http://www.listbox.com

Reply via email to