added aux/seek

aiju 2011-07-19 16:42:33 +02:00
parent 943b0d4609
commit 8f6173c8bd
2 changed files with 34 additions and 0 deletions

View File

@ -31,6 +31,7 @@ TARG=\
rdwr\
reboot\
searchfs\
seek\
statusbar\
stub\
tablet\

33
sys/src/cmd/aux/seek.c Normal file
View File

@ -0,0 +1,33 @@
#include <u.h>
#include <libc.h>
void
main(int argc, char **argv)
{
char buf[512];
vlong size;
vlong pos;
vlong ns;
int fd;
int i;
if(argc != 2) {
fprint(2, "usage: %s /dev/sd??/data\n", argv[0]);
exits("usage");
}
srand(time(0));
fd = open(argv[1], OREAD);
if(fd < 0)
sysfatal("open: %r");
size = seek(fd, 0, 2) / 512;
ns = nsec();
for(i=0;i<100;i++) {
pos = (vlong)(frand() * size);
if(pread(fd, buf, 512, 512 * pos) < 512)
sysfatal("read: %r");
}
ns = nsec() - ns;
print("%.3g\n", ((double)ns)/100000000);
exits(nil);
}