bash - Command line equivalent of `getrusage()` -
bash - Command line equivalent of `getrusage()` -
i'd track disk io given command does. getrusage()
can used in c; can same in command line somehow?
time
, times
show user , scheme time spent, latter including own/children breakdown, how other bits, disk io, spwap, peak memory?
an example:
[user@hsot ~]$ time sqlite3 haha.db vacuum real 1m6.439s user 0m7.407s sys 0m10.000s # i'd in add-on blocks in 1228349 blocks out 34523 maxrss 45634953 ...
ideally built bash (or whatever shell using). unfortunately there no such thing afaik.
but it's trivial create own wrapper using getrusage():
#include <stdio.h> #include <stdlib.h> #include <sys/resource.h> int main(int argc, char** argv) { system(argv[1]); struct rusage ru; getrusage(rusage_children, &ru); printf("\nblocks in:\t%li\nblocks out:\t%li\nmaxrss:\t\t%li\n", ru.ru_inblock, ru.ru_oublock, ru.ru_maxrss); }
compile it:
$ gcc -o process_io process_io.c
and utilize it:
$ ./process_io "dd if=/dev/urandom of=foobar bs=1k count=10000" 10000+0 records in 10000+0 records out 10240000 bytes (10 mb) copied, 0.922149 s, 11.1 mb/s blocks in: 0 blocks out: 80128 maxrss: 1676
bash command-line io
Comments
Post a Comment