Skip to content

Instantly share code, notes, and snippets.

@csw
Created August 2, 2012 06:11
Show Gist options
  • Save csw/3234330 to your computer and use it in GitHub Desktop.
Save csw/3234330 to your computer and use it in GitHub Desktop.
DTrace script to measure total I/O time
#!/usr/sbin/dtrace -s
syscall::read:entry
/execname == "sambamba"/
{
self->ts = timestamp;
self->fd = arg0;
}
syscall::read:return
/self->ts/
{
@time["read", fds[self->fd].fi_pathname] = sum(timestamp - self->ts);
self->ts = 0;
self->fd = 0;
}
syscall::write:entry
/execname == "sambamba"/
{
self->ts = timestamp;
self->fd = arg0;
}
syscall::write:return
/self->ts/
{
@time["write", fds[self->fd].fi_pathname] = sum(timestamp - self->ts);
self->ts = 0;
self->fd = 0;
}
syscall::write_nocancel:entry
/execname == "sambamba"/
{
self->ts = timestamp;
self->fd = arg0;
}
syscall::write_nocancel:return
/self->ts/
{
/* @time["write", fds[self->fd].fi_pathname] = sum(timestamp - self->ts); */
@time["write", "-"] = sum(timestamp - self->ts);
self->ts = 0;
self->fd = 0;
}
profile:::tick-1sec
{
normalize(@time, 1000000);
printa(@time);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment