-
-
Save lctrcl/0d2d4e1ca14ddc4979aef8f980356bd0 to your computer and use it in GitHub Desktop.
dtrace keystrokes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/sbin/dtrace -s | |
syscall::read:entry | |
/execname == "sh" || execname == "ksh" || execname == "csh" || | |
execname == "tcsh" || execname == "zsh" || execname == "bash"/ | |
{ | |
self->start = timestamp; | |
self->buf = arg1; | |
self->len = arg2; | |
} | |
syscall::read:return | |
/self->start && self->len == 1/ | |
{ | |
this->elapsed = timestamp - self->start; | |
@edist = quantize(this->elapsed / 1000000); | |
this->text = (char *) copyin(self->buf, self->len); | |
@ldist[stringof(this->text)] = quantize(this->elapsed / 1000000); | |
printf("%d ms %s letter", this->elapsed / 1000000, stringof(this->text)); | |
self->start = 0; | |
self->buf = NULL; | |
self->len = 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment