昨晚在sun的论坛问了一下,今天既然10几篇回复,真tmd热情。。。
完善了一下那个简单的脚本,应该可以用了。。。
#!/usr/sbin/dtrace -s
#pragma D option quiet
dtrace:::BEGIN
{
self->index = 0;
tstart = timestamp;
}
hotspot$1:::method-entry
{
mname = strjoin(strjoin(copyinstr(arg1,arg2),”->”),copyinstr(arg3,arg4));
self->index++;
self->mname[self->index] = mname;
self->mtime[self->index] = timestamp;
@count[mname] = count();
}
hotspot$1:::method-return
{
mname = strjoin(strjoin(copyinstr(arg1,arg2),”->”),copyinstr(arg3,arg4));
mindex = (self->mname[self->index] == mname) ? -1 : 0;
mtime = (mindex == -1) ? self->mtime[self->index] : tstart;
/*
mname = (mindex == -1) ? mname : strjoin(“non-start-“, mname);
printf(“method : %s : start : %d\n”, mname, tstart);
*/
@time[mname] = avg(timestamp – mtime);
self->index += mindex;
}
Leave a Reply