#include "stdinc.h" #include #include "dat.h" #include "fns.h" #include "error.h" int num = 100; int length = 20*1024; int block= 1024; int bush = 4; int iter = 100; Biobuf *bout; int maxdepth; Source *mkroot(Cache*); void new(Source*, int trace, int); int delete(Source*); int count(Source *s, int); void stats(Source *s); void dump(Source *s, int ident, ulong entry); static void bench(Source *r); void main(int argc, char *argv[]) { int i; Fs *fs; int csize = 1000; ulong t; Source *r; ARGBEGIN{ case 'i': iter = atoi(ARGF()); break; case 'n': num = atoi(ARGF()); break; case 'l': length = atoi(ARGF()); break; case 'b': block = atoi(ARGF()); break; case 'u': bush = atoi(ARGF()); break; case 'c': csize = atoi(ARGF()); break; }ARGEND; vtAttach(); bout = vtMemAllocZ(sizeof(Biobuf)); Binit(bout, 1, OWRITE); fmtinstall('V', vtScoreFmt); fmtinstall('R', vtErrFmt); fs = fsOpen(argv[0], nil, csize, OReadWrite); if(fs == nil) sysfatal("could not open fs: %r"); t = time(0); srand(0); r = fs->source; dump(r, 0, 0); fprint(2, "count = %d\n", count(r, 1)); for(i=0; i maxdepth) maxdepth = depth; Bflush(bout); n = sourceGetDirSize(s); for(i=0; idsize, 1+frand()>.5, 0); if(ss == nil){ Bprint(bout, "could not create directory: %R\n"); return; } if(trace){ int j; for(j=1; joffset); } sourceClose(ss); } int delete(Source *s) { int i, n; Source *ss; n = sourceGetDirSize(s); /* check if empty */ for(i=0; idir && delete(ss)){ sourceClose(ss); return 1; } if(1) break; sourceClose(ss); } sourceRemove(ss); return 1; } void dump(Source *s, int ident, ulong entry) { ulong i, n; Source *ss; Entry e; for(i=0; idir){ Bprint(bout, " data size: %llud\n", e.size); return; } n = sourceGetDirSize(s); Bprint(bout, " dir size: %lud\n", n); for(i=0; i max) max = c; sourceClose(ss); } fprint(2, "count = %d top = %d depth=%d maxcount %d\n", cc, n, maxdepth, max); }