免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2323 | 回复: 0
打印 上一主题 下一主题

DTrace 初步分析案例 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-12 17:16 |只看该作者 |倒序浏览

dtrace:::BEGIN
{
  /* save start time */
  start = timestamp;
  /* this is time spent on shortlived
processes */
  procs = 0;
  /* print header */
  printf("Sampling..
Hit Ctrl-C to stop.\n");
}
syscall::*fork*:entry
{
  /* save start of fork */
  self->fork = vtimestamp;
}
syscall::*fork*:return
/arg0 != 0 &&
self->fork/
{
  /* record elapsed time for the fork syscall */
  this->elapsed = vtimestamp -
self->fork;
  procs +=
this->elapsed;
  self->fork = 0;
}
syscall::*fork*:return
/arg0 == 0/
{
  /* save start of child process */
  self->start = vtimestamp;
  /* memory cleanup */
  self->fork = 0;
}
proc:::exit
/self->start/
{
  /* record elapsed time for process execution
*/
  this->elapsed = vtimestamp -
self->start;
  procs +=
this->elapsed;
  /* sum elapsed by process name and ppid */
  @Times_exec[execname] =
sum(this->elapsed/1000000);
  @Times_ppid[ppid] =
sum(this->elapsed/1000000);
  /* memory cleanup */
  self->start = 0;
}
dtrace:::END
{
  /* print report */
  this->total = timestamp - start;
  printf("short
lived processes: %6d.%03d secs\n",
   procs/1000000000,(procs%1000000000)/1000000);
  printf("total
sample duration: %6d.%03d secs\n",
   this->total/1000000000,(this->total%1000000000)/1000000);
  printf("\nTotal time by
process name,\n");
  printa("%18s
%@12d ms\n",@Times_exec);
  printf("\nTotal time by
PPID,\n");
  printa("%18d
%@12d ms\n",@Times_ppid);
}


本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/91236/showart_1793887.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP