PAPI  5.0.1.0
fileop.c
Go to the documentation of this file.
00001 /*
00002  * Author: Don Capps
00003  * 3/13/2006
00004  *
00005  *       Author: Don Capps (capps@iozone.org)
00006  *               7417 Crenshaw
00007  *               Plano, TX 75025
00008  *
00009  *  Copyright 2006, 2007, 2008, 2009   Don Capps.
00010  *
00011  *  License to freely use and distribute this software is hereby granted 
00012  *  by the author, subject to the condition that this copyright notice 
00013  *  remains intact.  The author retains the exclusive right to publish 
00014  *  derivative works based on this work, including, but not limited to,
00015  *  revised versions of this work",
00016  *
00017  *
00018   fileop [-f X ]|[-l # -u #] [-s Y] [-e] [-b] [-w] [-d <dir>] [-t] [-v] [-h]
00019        -f #      Force factor. X^3 files will be created and removed.
00020        -l #      Lower limit on the value of the Force factor.
00021        -u #      Upper limit on the value of the Force factor.
00022        -s #      Optional. Sets filesize for the create/write. May use suffix 'K' or 'M'.
00023        -e        Excel importable format.
00024        -b        Output best case.
00025        -w        Output worst case.
00026        -d <dir>  Specify starting directory.
00027        -U <dir>  Mount point to remount between tests.
00028        -t        Verbose output option.
00029        -v        Version information.
00030        -h        Help text.
00031  *
00032  * X is a force factor. The total number of files will
00033  *   be X * X * X   ( X ^ 3 )
00034  *   The structure of the file tree is:
00035  *   X number of Level 1 directories, with X number of
00036  *   level 2 directories, with X number of files in each
00037  *   of the level 2 directories.
00038  *
00039  *   Example:  fileop 2
00040  *
00041  *           dir_1                        dir_2
00042  *          /     \                      /     \
00043  *    sdir_1       sdir_2          sdir_1       sdir_2
00044  *    /     \     /     \          /     \      /     \
00045  * file_1 file_2 file_1 file_2   file_1 file_2 file_1 file_2
00046  *
00047  * Each file will be created, and then 1 byte is written to the file.
00048  *
00049  */
00050 
00051 #include <sys/types.h>
00052 #include <sys/stat.h>
00053 #include <fcntl.h>
00054 #include <sys/time.h>
00055 #include <stdlib.h>
00056 #include <stdio.h>
00057 #include <signal.h>
00058 #include <unistd.h>
00059 #include <dirent.h>
00060 #include <string.h>
00061 
00062 #include <limits.h>
00063 
00064 #if defined(Windows)
00065 #include <Windows.h>
00066 #endif
00067 #if !defined(PATH_MAX)
00068 #define PATH_MAX 255
00069 #endif
00070 
00071 #if defined(_SUA_)
00072 extern char *optarg;
00073 extern char *opterr;
00074 int fsync();
00075 int getopt();
00076 #endif
00077 int junk, *junkp;
00078 int x,excel;
00079 int verbose = 0;
00080 int sz = 1;
00081 char *mbuffer;
00082 int incr = 1;
00083 #define _STAT_CREATE 0
00084 #define _STAT_WRITE 1
00085 #define _STAT_CLOSE 2
00086 #define _STAT_LINK 3
00087 #define _STAT_UNLINK 4
00088 #define _STAT_DELETE 5
00089 #define _STAT_STAT 6
00090 #define _STAT_ACCESS 7
00091 #define _STAT_CHMOD 8
00092 #define _STAT_READDIR 9
00093 #define _STAT_DIR_CREATE 10
00094 #define _STAT_DIR_DELETE 11
00095 #define _STAT_READ 12
00096 #define _STAT_OPEN 13
00097 #define _STAT_DIR_TRAVERSE 14
00098 #define _NUM_STATS 15
00099 struct stat_struct {
00100     double starttime;
00101     double endtime;
00102     double speed;
00103     double best;
00104     double worst;
00105     double dummy;
00106     double total_time;
00107     double dummy1;
00108     long long counter;
00109 } volatile stats[_NUM_STATS];
00110 
00111 
00112 static double time_so_far(void);
00113 void dir_create(int);
00114 void dir_traverse(int);
00115 void dir_delete(int);
00116 void file_create(int);
00117 void file_stat(int);
00118 void file_access(int);
00119 void file_chmod(int);
00120 void file_readdir(int);
00121 void file_delete(int);
00122 void file_link(int);
00123 void file_unlink(int);
00124 void file_read(int);
00125 void splash(void);
00126 void usage(void);
00127 void bzero();
00128 void clear_stats();
00129 int validate(char *, int , char );
00130 
00131 #define THISVERSION "        $Revision$"
00132 /*#define NULL 0*/
00133 
00134 char version[]=THISVERSION;
00135 char thedir[PATH_MAX]="."; /* Default is to use the current directory */
00136 const char *mountname=NULL; /* Default is not to unmount anything between the tests */
00137 
00138 int cret;
00139 int lower, upper,range;
00140 int i;
00141 int best, worst;
00142 int dirlen;
00143 
00144 /************************************************************************/
00145 /* Routine to purge the buffer cache by unmounting drive.       */
00146 /************************************************************************/
00147 void purge_buffer_cache()
00148 {
00149     if (!mountname)
00150         return;
00151 
00152     char cwd[PATH_MAX];
00153     char command[1024];
00154     int ret,i;
00155 
00156     junkp=(int *)getcwd(cwd, sizeof(cwd));
00157     junk=chdir("/");
00158     strcpy(command,"umount ");
00159     strcat(command, mountname);
00160         /*
00161            umount might fail if the device is still busy, so
00162            retry unmounting several times with increasing delays
00163         */
00164         for (i = 1; i < 10; ++i) {
00165                ret = system(command);
00166                if (ret == 0)
00167                        break;
00168                sleep(i); /* seconds */
00169         }
00170     strcpy(command,"mount ");
00171     strcat(command, mountname);
00172     junk=system(command);
00173     junk=chdir(cwd);
00174 }
00175 
00176 int main(int argc, char **argv)
00177 {
00178     if(argc == 1)
00179     {
00180         usage();
00181         exit(1);
00182     }
00183     while((cret = getopt(argc,argv,"hbwetvf:s:l:u:d:U:i: ")) != EOF){
00184         switch(cret){
00185                 case 'h':
00186                         usage();
00187                         exit(0);
00188                         break;
00189                 case 'd' :
00190                         dirlen=strlen(optarg);
00191                         if (optarg[dirlen-1]=='/')
00192                           --dirlen;
00193                         strncpy(thedir, optarg, dirlen);
00194             thedir[dirlen] = 0;
00195                         break;
00196         case 'U':
00197             mountname = optarg;
00198             break;
00199         case 'i':   /* Increment force by */
00200             incr=atoi(optarg);
00201             if(incr < 0)
00202                 incr=1;
00203             break;
00204         case 'f':   /* Force factor */
00205             x=atoi(optarg);
00206             if(x < 0)
00207                 x=1;
00208             break;
00209         case 's':   /* Size of files */
00210                         sz=atoi(optarg);
00211                         if(optarg[strlen(optarg)-1]=='k' ||
00212                                 optarg[strlen(optarg)-1]=='K'){
00213                                 sz = (1024 * atoi(optarg));
00214                         }
00215                         if(optarg[strlen(optarg)-1]=='m' ||
00216                                 optarg[strlen(optarg)-1]=='M'){
00217                                 sz = (1024 * 1024 * atoi(optarg));
00218                         }
00219             if(sz < 0)
00220                 sz=1;
00221             break;
00222         case 'l':   /* lower force value */
00223             lower=atoi(optarg);
00224             range=1;
00225             if(lower < 0)
00226                 lower=1;
00227             break;
00228         case 'v':   /* version */
00229             splash();
00230             exit(0);
00231             break;
00232         case 'u':   /* upper force value */
00233             upper=atoi(optarg);
00234             range=1;
00235             if(upper < 0)
00236                 upper=1;
00237             break;
00238         case 't':   /* verbose */
00239             verbose=1;
00240             break;
00241         case 'e':   /* Excel */
00242             excel=1;
00243             break;
00244         case 'b':   /* Best */
00245             best=1;
00246             break;
00247         case 'w':   /* Worst */
00248             worst=1;
00249             break;
00250         }
00251     }
00252     mbuffer=(char *)malloc(sz);
00253     memset(mbuffer,'a',sz);
00254     if(!excel)
00255       printf("\nFileop:  Working in %s, File size is %d,  Output is in Ops/sec. (A=Avg, B=Best, W=Worst)\n", thedir, sz);
00256     if(!verbose)
00257     {
00258 #ifdef Windows
00259         printf(" .     %7s %7s %7s %7s %7s %7s %7s %7s %7s %7s %7s %7s %7s %10s\n",
00260             "mkdir","chdir","rmdir","create","open","read","write","close","stat",
00261         "access","chmod","readdir","delete"," Total_files");
00262 #else
00263 
00264         printf(" .     %7s %7s %7s %7s %7s %7s %7s %7s %7s %7s %7s %7s %7s %7s %7s %10s\n",
00265             "mkdir","chdir","rmdir","create","open", "read","write","close","stat",
00266         "access","chmod","readdir","link  ","unlink","delete",
00267         " Total_files");
00268 #endif
00269     }
00270     junk=chdir(thedir); /* change starting point */
00271     if(x==0)
00272         x=1;
00273     if(range==0)
00274         lower=upper=x;
00275     for(i=lower;i<=upper;i+=incr)
00276     {
00277         clear_stats();
00278         x=i;
00279        /*
00280         * Dir Create test 
00281         */
00282        purge_buffer_cache();
00283        dir_create(x);
00284 
00285        if(verbose)
00286        {
00287           printf("mkdir:   Dirs = %9lld ",stats[_STAT_DIR_CREATE].counter);
00288           printf("Total Time = %12.9f seconds\n", stats[_STAT_DIR_CREATE].total_time);
00289           printf("         Avg mkdir(s)/sec     = %12.2f (%12.9f seconds/op)\n",
00290             stats[_STAT_DIR_CREATE].counter/stats[_STAT_DIR_CREATE].total_time,
00291             stats[_STAT_DIR_CREATE].total_time/stats[_STAT_DIR_CREATE].counter);
00292           printf("         Best mkdir(s)/sec    = %12.2f (%12.9f seconds/op)\n",1/stats[_STAT_DIR_CREATE].best,stats[_STAT_DIR_CREATE].best);
00293           printf("         Worst mkdir(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",1/stats[_STAT_DIR_CREATE].worst,stats[_STAT_DIR_CREATE].worst);
00294        }
00295 
00296        /*
00297         * Dir Traverse test
00298         */
00299        purge_buffer_cache();
00300        dir_traverse(x);
00301 
00302        if(verbose)
00303        {
00304           printf("chdir:   Dirs = %9lld ",stats[_STAT_DIR_TRAVERSE].counter);
00305           printf("Total Time = %12.9f seconds\n", stats[_STAT_DIR_TRAVERSE].total_time);
00306           printf("         Avg chdir(s)/sec     = %12.2f (%12.9f seconds/op)\n",
00307             stats[_STAT_DIR_TRAVERSE].counter/stats[_STAT_DIR_TRAVERSE].total_time,
00308             stats[_STAT_DIR_TRAVERSE].total_time/stats[_STAT_DIR_TRAVERSE].counter);
00309           printf("         Best chdir(s)/sec    = %12.2f (%12.9f seconds/op)\n",1/stats[_STAT_DIR_TRAVERSE].best,stats[_STAT_DIR_TRAVERSE].best);
00310           printf("         Worst chdir(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",1/stats[_STAT_DIR_TRAVERSE].worst,stats[_STAT_DIR_TRAVERSE].worst);
00311        }
00312 
00313        /*
00314         * Dir delete test
00315         */
00316        purge_buffer_cache();
00317        dir_delete(x);
00318 
00319        if(verbose)
00320        {
00321        printf("rmdir:   Dirs = %9lld ",stats[_STAT_DIR_DELETE].counter);
00322        printf("Total Time = %12.9f seconds\n",stats[_STAT_DIR_DELETE].total_time);
00323        printf("         Avg rmdir(s)/sec     = %12.2f (%12.9f seconds/op)\n",
00324             stats[_STAT_DIR_DELETE].counter/stats[_STAT_DIR_DELETE].total_time,
00325             stats[_STAT_DIR_DELETE].total_time/stats[_STAT_DIR_DELETE].counter);
00326        printf("         Best rmdir(s)/sec    = %12.2f (%12.9f seconds/op)\n",1/stats[_STAT_DIR_DELETE].best,stats[_STAT_DIR_DELETE].best);
00327        printf("         Worst rmdir(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",1/stats[_STAT_DIR_DELETE].worst,stats[_STAT_DIR_DELETE].worst);
00328        }
00329 
00330        /*
00331         * Create test 
00332         */
00333        purge_buffer_cache();
00334        file_create(x);
00335        if(verbose)
00336        {
00337           printf("create:  Files = %9lld ",stats[_STAT_CREATE].counter);
00338           printf("Total Time = %12.9f seconds\n", stats[_STAT_CREATE].total_time);
00339           printf("         Avg create(s)/sec    = %12.2f (%12.9f seconds/op)\n",
00340             stats[_STAT_CREATE].counter/stats[_STAT_CREATE].total_time,
00341             stats[_STAT_CREATE].total_time/stats[_STAT_CREATE].counter);
00342           printf("         Best create(s)/sec   = %12.2f (%12.9f seconds/op)\n",
00343             1/stats[_STAT_CREATE].best,stats[_STAT_CREATE].best);
00344           printf("         Worst create(s)/sec  = %12.2f (%12.9f seconds/op)\n\n",
00345             1/stats[_STAT_CREATE].worst,stats[_STAT_CREATE].worst);
00346           printf("write:   Files = %9lld ",stats[_STAT_WRITE].counter);
00347           printf("Total Time = %12.9f seconds\n", stats[_STAT_WRITE].total_time);
00348           printf("         Avg write(s)/sec     = %12.2f (%12.9f seconds/op)\n",
00349             stats[_STAT_WRITE].counter/stats[_STAT_WRITE].total_time,
00350             stats[_STAT_WRITE].total_time/stats[_STAT_WRITE].counter);
00351           printf("         Best write(s)/sec    = %12.2f (%12.9f seconds/op)\n",
00352             1/stats[_STAT_WRITE].best,stats[_STAT_WRITE].best);
00353           printf("         Worst write(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",
00354             1/stats[_STAT_WRITE].worst,stats[_STAT_WRITE].worst);
00355           printf("close:   Files = %9lld ",stats[_STAT_CLOSE].counter);
00356           printf("Total Time = %12.9f seconds\n", stats[_STAT_CLOSE].total_time);
00357           printf("         Avg close(s)/sec     = %12.2f (%12.9f seconds/op)\n",
00358             stats[_STAT_CLOSE].counter/stats[_STAT_CLOSE].total_time,
00359             stats[_STAT_CLOSE].total_time/stats[_STAT_CLOSE].counter);
00360           printf("         Best close(s)/sec    = %12.2f (%12.9f seconds/op)\n",
00361             1/stats[_STAT_CLOSE].best,stats[_STAT_CLOSE].best);
00362           printf("         Worst close(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",
00363             1/stats[_STAT_CLOSE].worst,stats[_STAT_CLOSE].worst);
00364        }
00365 
00366        /*
00367         * Stat test 
00368         */
00369        purge_buffer_cache();
00370        file_stat(x);
00371 
00372        if(verbose)
00373        {
00374           printf("stat:    Files = %9lld ",stats[_STAT_STAT].counter);
00375           printf("Total Time = %12.9f seconds\n", stats[_STAT_STAT].total_time);
00376           printf("         Avg stat(s)/sec      = %12.2f (%12.9f seconds/op)\n",
00377             stats[_STAT_STAT].counter/stats[_STAT_STAT].total_time,
00378             stats[_STAT_STAT].total_time/stats[_STAT_STAT].counter);
00379           printf("         Best stat(s)/sec     = %12.2f (%12.9f seconds/op)\n",
00380             1/stats[_STAT_STAT].best,stats[_STAT_STAT].best);
00381           printf("         Worst stat(s)/sec    = %12.2f (%12.9f seconds/op)\n\n",
00382             1/stats[_STAT_STAT].worst,stats[_STAT_STAT].worst);
00383        }
00384        /*
00385         * Read test 
00386         */
00387        purge_buffer_cache();
00388        file_read(x);
00389 
00390        if(verbose)
00391        {
00392           printf("open:    Files = %9lld ",stats[_STAT_OPEN].counter);
00393           printf("Total Time = %12.9f seconds\n", stats[_STAT_OPEN].total_time);
00394           printf("         Avg open(s)/sec      = %12.2f (%12.9f seconds/op)\n",
00395             stats[_STAT_OPEN].counter/stats[_STAT_OPEN].total_time,
00396             stats[_STAT_OPEN].total_time/stats[_STAT_OPEN].counter);
00397           printf("         Best open(s)/sec     = %12.2f (%12.9f seconds/op)\n",
00398             1/stats[_STAT_OPEN].best,stats[_STAT_OPEN].best);
00399           printf("         Worst open(s)/sec    = %12.2f (%12.9f seconds/op)\n\n",
00400             1/stats[_STAT_OPEN].worst,stats[_STAT_OPEN].worst);
00401 
00402           printf("read:    Files = %9lld ",stats[_STAT_READ].counter);
00403           printf("Total Time = %12.9f seconds\n", stats[_STAT_READ].total_time);
00404           printf("         Avg read(s)/sec      = %12.2f (%12.9f seconds/op)\n",
00405             stats[_STAT_READ].counter/stats[_STAT_READ].total_time,
00406             stats[_STAT_READ].total_time/stats[_STAT_READ].counter);
00407           printf("         Best read(s)/sec     = %12.2f (%12.9f seconds/op)\n",
00408             1/stats[_STAT_READ].best,stats[_STAT_READ].best);
00409           printf("         Worst read(s)/sec    = %12.2f (%12.9f seconds/op)\n\n",
00410             1/stats[_STAT_READ].worst,stats[_STAT_READ].worst);
00411        }
00412 
00413        /*
00414         * Access test 
00415         */
00416        purge_buffer_cache();
00417        file_access(x);
00418        if(verbose)
00419        {
00420           printf("access:  Files = %9lld ",stats[_STAT_ACCESS].counter);
00421           printf("Total Time = %12.9f seconds\n", stats[_STAT_ACCESS].total_time);
00422           printf("         Avg access(s)/sec    = %12.2f (%12.9f seconds/op)\n",
00423             stats[_STAT_ACCESS].counter/stats[_STAT_ACCESS].total_time,
00424             stats[_STAT_ACCESS].total_time/stats[_STAT_ACCESS].counter);
00425           printf("         Best access(s)/sec   = %12.2f (%12.9f seconds/op)\n",
00426             1/stats[_STAT_ACCESS].best,stats[_STAT_ACCESS].best);
00427           printf("         Worst access(s)/sec  = %12.2f (%12.9f seconds/op)\n\n",
00428             1/stats[_STAT_ACCESS].worst,stats[_STAT_ACCESS].worst);
00429        }
00430        /*
00431         * Chmod test 
00432         */
00433        purge_buffer_cache();
00434        file_chmod(x);
00435 
00436        if(verbose)
00437        {
00438           printf("chmod:   Files = %9lld ",stats[_STAT_CHMOD].counter);
00439           printf("Total Time = %12.9f seconds\n", stats[_STAT_CHMOD].total_time);
00440           printf("         Avg chmod(s)/sec     = %12.2f (%12.9f seconds/op)\n",
00441             stats[_STAT_CHMOD].counter/stats[_STAT_CHMOD].total_time,
00442             stats[_STAT_CHMOD].total_time/stats[_STAT_CHMOD].counter);
00443           printf("         Best chmod(s)/sec    = %12.2f (%12.9f seconds/op)\n",
00444             1/stats[_STAT_CHMOD].best,stats[_STAT_CHMOD].best);
00445           printf("         Worst chmod(s)/sec   = %12.2f (%12.9f seconds/op)\n\n",
00446             1/stats[_STAT_CHMOD].worst,stats[_STAT_CHMOD].worst);
00447        }
00448        /*
00449         * readdir test 
00450         */
00451        purge_buffer_cache();
00452        file_readdir(x);
00453 
00454        if(verbose)
00455        {
00456           printf("readdir: Files = %9lld ",stats[_STAT_READDIR].counter);
00457           printf("Total Time = %12.9f seconds\n", stats[_STAT_READDIR].total_time);
00458           printf("         Avg readdir(s)/sec   = %12.2f (%12.9f seconds/op)\n",
00459             stats[_STAT_READDIR].counter/stats[_STAT_READDIR].total_time,
00460             stats[_STAT_READDIR].total_time/stats[_STAT_READDIR].counter);
00461           printf("         Best readdir(s)/sec  = %12.2f (%12.9f seconds/op)\n",
00462             1/stats[_STAT_READDIR].best,stats[_STAT_READDIR].best);
00463           printf("         Worst readdir(s)/sec = %12.2f (%12.9f seconds/op)\n\n",
00464             1/stats[_STAT_READDIR].worst,stats[_STAT_READDIR].worst);
00465        }
00466 #if !defined(Windows)
00467        /*
00468         * link test 
00469         */
00470        purge_buffer_cache();
00471        file_link(x);
00472        if(verbose)
00473        {
00474           printf("link:    Files = %9lld ",stats[_STAT_LINK].counter);
00475           printf("Total Time = %12.9f seconds\n",stats[_STAT_LINK].total_time);
00476           printf("         Avg link(s)/sec      = %12.2f (%12.9f seconds/op)\n",
00477             stats[_STAT_LINK].counter/stats[_STAT_LINK].total_time,
00478             stats[_STAT_LINK].total_time/stats[_STAT_LINK].counter);
00479           printf("         Best link(s)/sec     = %12.2f (%12.9f seconds/op)\n",
00480             1/stats[_STAT_LINK].best,stats[_STAT_LINK].best);
00481           printf("         Worst link(s)/sec    = %12.2f (%12.9f seconds/op)\n\n",
00482             1/stats[_STAT_LINK].worst,stats[_STAT_LINK].worst);
00483        }
00484        /*
00485         * unlink test 
00486         */
00487        purge_buffer_cache();
00488        file_unlink(x);
00489        if(verbose)
00490        {
00491           printf("unlink:  Files = %9lld ",stats[_STAT_UNLINK].counter);
00492           printf("Total Time = %12.9f seconds\n", stats[_STAT_UNLINK].total_time);
00493           printf("         Avg unlink(s)/sec    = %12.2f (%12.9f seconds/op)\n",
00494             stats[_STAT_UNLINK].counter/stats[_STAT_UNLINK].total_time,
00495             stats[_STAT_UNLINK].total_time/stats[_STAT_UNLINK].counter);
00496           printf("         Best unlink(s)/sec   = %12.2f (%12.9f seconds/op)\n",
00497             1/stats[_STAT_UNLINK].best,stats[_STAT_UNLINK].best);
00498           printf("         Worst unlink(s)/sec  = %12.2f (%12.9f seconds/op)\n\n",
00499             1/stats[_STAT_UNLINK].worst,stats[_STAT_UNLINK].worst);
00500        }
00501 #endif
00502        /*
00503         * Delete test 
00504         */
00505        purge_buffer_cache();
00506        file_delete(x);
00507        if(verbose)
00508        {
00509           printf("delete:  Files = %9lld ",stats[_STAT_DELETE].counter);
00510           printf("Total Time = %12.9f seconds\n", stats[_STAT_DELETE].total_time);
00511           printf("         Avg delete(s)/sec    = %12.2f (%12.9f seconds/op)\n",
00512             stats[_STAT_DELETE].counter/stats[_STAT_DELETE].total_time,
00513             stats[_STAT_DELETE].total_time/stats[_STAT_DELETE].counter);
00514           printf("         Best delete(s)/sec   = %12.2f (%12.9f seconds/op)\n",
00515             1/stats[_STAT_DELETE].best,stats[_STAT_DELETE].best);
00516           printf("         Worst delete(s)/sec  = %12.2f (%12.9f seconds/op)\n\n",
00517             1/stats[_STAT_DELETE].worst,stats[_STAT_DELETE].worst);
00518        }
00519        if(!verbose)
00520        {
00521              printf("%c %4d %7.0f ",'A',x,stats[_STAT_DIR_CREATE].counter/stats[_STAT_DIR_CREATE].total_time);
00522              printf("%7.0f ",stats[_STAT_DIR_TRAVERSE].counter/stats[_STAT_DIR_TRAVERSE].total_time);
00523              printf("%7.0f ",stats[_STAT_DIR_DELETE].counter/stats[_STAT_DIR_DELETE].total_time);
00524              printf("%7.0f ",stats[_STAT_CREATE].counter/stats[_STAT_CREATE].total_time);
00525              printf("%7.0f ",stats[_STAT_OPEN].counter/stats[_STAT_OPEN].total_time);
00526              printf("%7.0f ",stats[_STAT_READ].counter/stats[_STAT_READ].total_time);
00527              printf("%7.0f ",stats[_STAT_WRITE].counter/stats[_STAT_WRITE].total_time);
00528              printf("%7.0f ",stats[_STAT_CLOSE].counter/stats[_STAT_CLOSE].total_time);
00529              printf("%7.0f ",stats[_STAT_STAT].counter/stats[_STAT_STAT].total_time);
00530              printf("%7.0f ",stats[_STAT_ACCESS].counter/stats[_STAT_ACCESS].total_time);
00531              printf("%7.0f ",stats[_STAT_CHMOD].counter/stats[_STAT_CHMOD].total_time);
00532              printf("%7.0f ",stats[_STAT_READDIR].counter/stats[_STAT_READDIR].total_time);
00533 #ifndef Windows
00534              printf("%7.0f ",stats[_STAT_LINK].counter/stats[_STAT_LINK].total_time);
00535              printf("%7.0f ",stats[_STAT_UNLINK].counter/stats[_STAT_UNLINK].total_time);
00536 #endif
00537              printf("%7.0f ",stats[_STAT_DELETE].counter/stats[_STAT_DELETE].total_time);
00538              printf("%10d ",x*x*x);
00539              printf("\n");
00540          fflush(stdout);
00541 
00542         if(best)
00543         {
00544              printf("%c %4d %7.0f ",'B',x, 1/stats[_STAT_DIR_CREATE].best);
00545              printf("%7.0f ",1/stats[_STAT_DIR_TRAVERSE].best);
00546              printf("%7.0f ",1/stats[_STAT_DIR_DELETE].best);
00547              printf("%7.0f ",1/stats[_STAT_CREATE].best);
00548              printf("%7.0f ",1/stats[_STAT_OPEN].best);
00549              printf("%7.0f ",1/stats[_STAT_READ].best);
00550              printf("%7.0f ",1/stats[_STAT_WRITE].best);
00551              printf("%7.0f ",1/stats[_STAT_CLOSE].best);
00552              printf("%7.0f ",1/stats[_STAT_STAT].best);
00553              printf("%7.0f ",1/stats[_STAT_ACCESS].best);
00554              printf("%7.0f ",1/stats[_STAT_CHMOD].best);
00555              printf("%7.0f ",1/stats[_STAT_READDIR].best);
00556 #ifndef Windows
00557              printf("%7.0f ",1/stats[_STAT_LINK].best);
00558              printf("%7.0f ",1/stats[_STAT_UNLINK].best);
00559 #endif
00560              printf("%7.0f ",1/stats[_STAT_DELETE].best);
00561              printf("%10d ",x*x*x);
00562          printf("\n");
00563          fflush(stdout);
00564         }
00565         if(worst)
00566         {
00567              printf("%c %4d %7.0f ",'W',x, 1/stats[_STAT_DIR_CREATE].worst);
00568              printf("%7.0f ",1/stats[_STAT_DIR_TRAVERSE].worst);
00569              printf("%7.0f ",1/stats[_STAT_DIR_DELETE].worst);
00570              printf("%7.0f ",1/stats[_STAT_CREATE].worst);
00571              printf("%7.0f ",1/stats[_STAT_OPEN].worst);
00572              printf("%7.0f ",1/stats[_STAT_READ].worst);
00573              printf("%7.0f ",1/stats[_STAT_WRITE].worst);
00574              printf("%7.0f ",1/stats[_STAT_CLOSE].worst);
00575              printf("%7.0f ",1/stats[_STAT_STAT].worst);
00576              printf("%7.0f ",1/stats[_STAT_ACCESS].worst);
00577              printf("%7.0f ",1/stats[_STAT_CHMOD].worst);
00578              printf("%7.0f ",1/stats[_STAT_READDIR].worst);
00579 #ifndef Windows
00580              printf("%7.0f ",1/stats[_STAT_LINK].worst);
00581              printf("%7.0f ",1/stats[_STAT_UNLINK].worst);
00582 #endif
00583              printf("%7.0f ",1/stats[_STAT_DELETE].worst);
00584              printf("%10d ",x*x*x);
00585          printf("\n");
00586          fflush(stdout);
00587         }
00588        }
00589     }
00590     return(0);
00591 }
00592 
00593 void 
00594 dir_create(int x)
00595 {
00596     int i,j,k;
00597     int ret;
00598     char buf[100];
00599     stats[_STAT_DIR_CREATE].best=(double)99999.9;
00600     stats[_STAT_DIR_CREATE].worst=(double)0.00000000;
00601     for(i=0;i<x;i++)
00602     {
00603       sprintf(buf,"fileop_L1_%d",i);
00604       stats[_STAT_DIR_CREATE].starttime=time_so_far();
00605       ret=mkdir(buf,0777);
00606       if(ret < 0)
00607       {
00608           printf("Mkdir failed\n");
00609           exit(1);
00610       }
00611       stats[_STAT_DIR_CREATE].endtime=time_so_far();
00612       stats[_STAT_DIR_CREATE].speed=stats[_STAT_DIR_CREATE].endtime-stats[_STAT_DIR_CREATE].starttime;
00613       if(stats[_STAT_DIR_CREATE].speed < (double)0.0)
00614         stats[_STAT_DIR_CREATE].speed=(double)0.0;
00615       stats[_STAT_DIR_CREATE].total_time+=stats[_STAT_DIR_CREATE].speed;
00616       stats[_STAT_DIR_CREATE].counter++;
00617       if(stats[_STAT_DIR_CREATE].speed < stats[_STAT_DIR_CREATE].best)
00618         stats[_STAT_DIR_CREATE].best=stats[_STAT_DIR_CREATE].speed;
00619       if(stats[_STAT_DIR_CREATE].speed > stats[_STAT_DIR_CREATE].worst)
00620          stats[_STAT_DIR_CREATE].worst=stats[_STAT_DIR_CREATE].speed;
00621       junk=chdir(buf);
00622       for(j=0;j<x;j++)
00623       {
00624         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
00625         stats[_STAT_DIR_CREATE].starttime=time_so_far();
00626         ret=mkdir(buf,0777);
00627         if(ret < 0)
00628         {
00629           printf("Mkdir failed\n");
00630           exit(1);
00631         }
00632         stats[_STAT_DIR_CREATE].endtime=time_so_far();
00633         stats[_STAT_DIR_CREATE].speed=stats[_STAT_DIR_CREATE].endtime-stats[_STAT_DIR_CREATE].starttime;
00634         if(stats[_STAT_DIR_CREATE].speed < (double)0.0)
00635         stats[_STAT_DIR_CREATE].speed=(double) 0.0;
00636         stats[_STAT_DIR_CREATE].total_time+=stats[_STAT_DIR_CREATE].speed;
00637         stats[_STAT_DIR_CREATE].counter++;
00638         if(stats[_STAT_DIR_CREATE].speed < stats[_STAT_DIR_CREATE].best)
00639          stats[_STAT_DIR_CREATE].best=stats[_STAT_DIR_CREATE].speed;
00640         if(stats[_STAT_DIR_CREATE].speed > stats[_STAT_DIR_CREATE].worst)
00641          stats[_STAT_DIR_CREATE].worst=stats[_STAT_DIR_CREATE].speed;
00642         junk=chdir(buf);
00643         for(k=0;k<x;k++)
00644         {
00645           sprintf(buf,"fileop_dir_%d_%d_%d",i,j,k);
00646           stats[_STAT_DIR_CREATE].starttime=time_so_far();
00647           ret=mkdir(buf,0777);
00648           if(ret < 0)
00649           {
00650             printf("Mkdir failed\n");
00651             exit(1);
00652           }
00653           stats[_STAT_DIR_CREATE].endtime=time_so_far();
00654           stats[_STAT_DIR_CREATE].speed=stats[_STAT_DIR_CREATE].endtime-stats[_STAT_DIR_CREATE].starttime;
00655           if(stats[_STAT_DIR_CREATE].speed < (double)0.0)
00656         stats[_STAT_DIR_CREATE].speed=(double) 0.0;
00657           stats[_STAT_DIR_CREATE].total_time+=stats[_STAT_DIR_CREATE].speed;
00658           stats[_STAT_DIR_CREATE].counter++;
00659           if(stats[_STAT_DIR_CREATE].speed < stats[_STAT_DIR_CREATE].best)
00660          stats[_STAT_DIR_CREATE].best=stats[_STAT_DIR_CREATE].speed;
00661           if(stats[_STAT_DIR_CREATE].speed > stats[_STAT_DIR_CREATE].worst)
00662          stats[_STAT_DIR_CREATE].worst=stats[_STAT_DIR_CREATE].speed;
00663           junk=chdir(buf);
00664           junk=chdir("..");
00665         }
00666         junk=chdir("..");
00667       }
00668       junk=chdir("..");
00669     }
00670 }
00671 
00672 void
00673 dir_traverse(int x)
00674 {
00675     int i,j,k;
00676     char buf[100];
00677     double time1, time2;
00678     stats[_STAT_DIR_TRAVERSE].best=(double)99999.9;
00679     stats[_STAT_DIR_TRAVERSE].worst=(double)0.00000000;
00680     for(i=0;i<x;i++)
00681     {
00682       sprintf(buf,"fileop_L1_%d",i);
00683       stats[_STAT_DIR_TRAVERSE].starttime=time_so_far();
00684       junk=chdir(buf);
00685       stats[_STAT_DIR_TRAVERSE].endtime=time_so_far();
00686       time1=stats[_STAT_DIR_TRAVERSE].endtime-stats[_STAT_DIR_TRAVERSE].starttime;
00687       for(j=0;j<x;j++)
00688       {
00689         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
00690         stats[_STAT_DIR_TRAVERSE].starttime=time_so_far();
00691         junk=chdir(buf);
00692         stats[_STAT_DIR_TRAVERSE].endtime=time_so_far();
00693         time2=stats[_STAT_DIR_TRAVERSE].endtime-stats[_STAT_DIR_TRAVERSE].starttime;
00694         for(k=0;k<x;k++)
00695         {
00696           sprintf(buf,"fileop_dir_%d_%d_%d",i,j,k);
00697           stats[_STAT_DIR_TRAVERSE].starttime=time_so_far();
00698           junk=chdir(buf);
00699           junk=chdir("..");
00700           stats[_STAT_DIR_TRAVERSE].endtime=time_so_far();
00701           stats[_STAT_DIR_TRAVERSE].speed=stats[_STAT_DIR_TRAVERSE].endtime-stats[_STAT_DIR_TRAVERSE].starttime;
00702           if(stats[_STAT_DIR_TRAVERSE].speed < (double)0.0)
00703         stats[_STAT_DIR_TRAVERSE].speed=(double) 0.0;
00704           stats[_STAT_DIR_TRAVERSE].total_time+=stats[_STAT_DIR_TRAVERSE].speed;
00705           stats[_STAT_DIR_TRAVERSE].counter++;
00706           if(stats[_STAT_DIR_TRAVERSE].speed < stats[_STAT_DIR_TRAVERSE].best)
00707          stats[_STAT_DIR_TRAVERSE].best=stats[_STAT_DIR_TRAVERSE].speed;
00708           if(stats[_STAT_DIR_TRAVERSE].speed > stats[_STAT_DIR_TRAVERSE].worst)
00709          stats[_STAT_DIR_TRAVERSE].worst=stats[_STAT_DIR_TRAVERSE].speed;
00710         }
00711         stats[_STAT_DIR_TRAVERSE].starttime=time_so_far();
00712         junk=chdir("..");
00713         stats[_STAT_DIR_TRAVERSE].endtime=time_so_far();
00714         stats[_STAT_DIR_TRAVERSE].speed=time2+stats[_STAT_DIR_TRAVERSE].endtime-stats[_STAT_DIR_TRAVERSE].starttime;
00715         if(stats[_STAT_DIR_TRAVERSE].speed < (double)0.0)
00716         stats[_STAT_DIR_TRAVERSE].speed=(double) 0.0;
00717         stats[_STAT_DIR_TRAVERSE].total_time+=stats[_STAT_DIR_TRAVERSE].speed;
00718         stats[_STAT_DIR_TRAVERSE].counter++;
00719         if(stats[_STAT_DIR_TRAVERSE].speed < stats[_STAT_DIR_TRAVERSE].best)
00720          stats[_STAT_DIR_TRAVERSE].best=stats[_STAT_DIR_TRAVERSE].speed;
00721         if(stats[_STAT_DIR_TRAVERSE].speed > stats[_STAT_DIR_TRAVERSE].worst)
00722          stats[_STAT_DIR_TRAVERSE].worst=stats[_STAT_DIR_TRAVERSE].speed;
00723       }
00724       stats[_STAT_DIR_TRAVERSE].starttime=time_so_far();
00725       junk=chdir("..");
00726       stats[_STAT_DIR_TRAVERSE].endtime=time_so_far();
00727       stats[_STAT_DIR_TRAVERSE].speed=time1+stats[_STAT_DIR_TRAVERSE].endtime-stats[_STAT_DIR_TRAVERSE].starttime;
00728       if(stats[_STAT_DIR_TRAVERSE].speed < (double)0.0)
00729         stats[_STAT_DIR_TRAVERSE].speed=(double)0.0;
00730       stats[_STAT_DIR_TRAVERSE].total_time+=stats[_STAT_DIR_TRAVERSE].speed;
00731       stats[_STAT_DIR_TRAVERSE].counter++;
00732       if(stats[_STAT_DIR_TRAVERSE].speed < stats[_STAT_DIR_TRAVERSE].best)
00733         stats[_STAT_DIR_TRAVERSE].best=stats[_STAT_DIR_TRAVERSE].speed;
00734       if(stats[_STAT_DIR_TRAVERSE].speed > stats[_STAT_DIR_TRAVERSE].worst)
00735          stats[_STAT_DIR_TRAVERSE].worst=stats[_STAT_DIR_TRAVERSE].speed;
00736     }
00737 }
00738 
00739 void 
00740 file_create(int x)
00741 {
00742     int i,j,k;
00743     int fd;
00744     int ret;
00745     char buf[100];
00746     char value;
00747     stats[_STAT_CREATE].best=(double)999999.9;
00748     stats[_STAT_CREATE].worst=(double)0.0;
00749     stats[_STAT_WRITE].best=(double)999999.9;
00750     stats[_STAT_WRITE].worst=(double)0.0;
00751     stats[_STAT_CLOSE].best=(double)999999.9;
00752     stats[_STAT_CLOSE].worst=(double)0.0;
00753     for(i=0;i<x;i++)
00754     {
00755       sprintf(buf,"fileop_L1_%d",i);
00756       ret=mkdir(buf,0777);
00757       if(ret < 0)
00758       {
00759           printf("Mkdir failed\n");
00760           exit(1);
00761       }
00762       junk=chdir(buf);
00763       for(j=0;j<x;j++)
00764       {
00765         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
00766         ret=mkdir(buf,0777);
00767         if(ret < 0)
00768         {
00769           printf("Mkdir failed\n");
00770           exit(1);
00771         }
00772         junk=chdir(buf);
00773         for(k=0;k<x;k++)
00774         {
00775           sprintf(buf,"fileop_file_%d_%d_%d",i,j,k);
00776           value=(char) ((i^j^k) & 0xff);
00777           memset(mbuffer,value,sz);
00778           stats[_STAT_CREATE].starttime=time_so_far();
00779           fd=creat(buf,O_RDWR|0600);
00780           if(fd < 0)
00781           {
00782             printf("Create failed\n");
00783             exit(1);
00784           }
00785           stats[_STAT_CREATE].endtime=time_so_far();
00786           stats[_STAT_CREATE].speed=stats[_STAT_CREATE].endtime-stats[_STAT_CREATE].starttime;
00787           if(stats[_STAT_CREATE].speed < (double)0.0)
00788         stats[_STAT_CREATE].speed=(double)0.0;
00789           stats[_STAT_CREATE].total_time+=stats[_STAT_CREATE].speed;
00790           stats[_STAT_CREATE].counter++;
00791           if(stats[_STAT_CREATE].speed < stats[_STAT_CREATE].best)
00792          stats[_STAT_CREATE].best=stats[_STAT_CREATE].speed;
00793           if(stats[_STAT_CREATE].speed > stats[_STAT_CREATE].worst)
00794          stats[_STAT_CREATE].worst=stats[_STAT_CREATE].speed;
00795 
00796           stats[_STAT_WRITE].starttime=time_so_far();
00797           junk=write(fd,mbuffer,sz);
00798           stats[_STAT_WRITE].endtime=time_so_far();
00799           stats[_STAT_WRITE].counter++;
00800           stats[_STAT_WRITE].speed=stats[_STAT_WRITE].endtime-stats[_STAT_WRITE].starttime;
00801           if(stats[_STAT_WRITE].speed < (double)0.0)
00802         stats[_STAT_WRITE].speed=(double)0.0;
00803           stats[_STAT_WRITE].total_time+=stats[_STAT_WRITE].speed;
00804           if(stats[_STAT_WRITE].speed < stats[_STAT_WRITE].best)
00805          stats[_STAT_WRITE].best=stats[_STAT_WRITE].speed;
00806           if(stats[_STAT_WRITE].speed > stats[_STAT_WRITE].worst)
00807          stats[_STAT_WRITE].worst=stats[_STAT_WRITE].speed;
00808 
00809           fsync(fd);
00810           stats[_STAT_CLOSE].starttime=time_so_far();
00811           close(fd);
00812           stats[_STAT_CLOSE].endtime=time_so_far();
00813           stats[_STAT_CLOSE].speed=stats[_STAT_CLOSE].endtime-stats[_STAT_CLOSE].starttime;
00814           if(stats[_STAT_CLOSE].speed < (double)0.0)
00815         stats[_STAT_CLOSE].speed=(double)0.0;
00816           stats[_STAT_CLOSE].total_time+=stats[_STAT_CLOSE].speed;
00817           stats[_STAT_CLOSE].counter++;
00818           if(stats[_STAT_CLOSE].speed < stats[_STAT_CLOSE].best)
00819          stats[_STAT_CLOSE].best=stats[_STAT_CLOSE].speed;
00820           if(stats[_STAT_CLOSE].speed > stats[_STAT_CLOSE].worst)
00821          stats[_STAT_CLOSE].worst=stats[_STAT_CLOSE].speed;
00822         }
00823         junk=chdir("..");
00824       }
00825       junk=chdir("..");
00826     }
00827 }
00828 
00829 void 
00830 file_stat(int x)
00831 {
00832     int i,j,k,y;
00833     char buf[100];
00834     struct stat mystat;
00835     stats[_STAT_STAT].best=(double)99999.9;
00836     stats[_STAT_STAT].worst=(double)0.00000000;
00837     for(i=0;i<x;i++)
00838     {
00839       sprintf(buf,"fileop_L1_%d",i);
00840       junk=chdir(buf);
00841       for(j=0;j<x;j++)
00842       {
00843         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
00844         junk=chdir(buf);
00845         for(k=0;k<x;k++)
00846         {
00847           sprintf(buf,"fileop_file_%d_%d_%d",i,j,k);
00848           stats[_STAT_STAT].starttime=time_so_far();
00849           y=stat(buf,&mystat);
00850           if(y < 0)
00851           {
00852             printf("Stat failed\n");
00853             exit(1);
00854           }
00855           stats[_STAT_STAT].endtime=time_so_far();
00856           stats[_STAT_STAT].speed=stats[_STAT_STAT].endtime-stats[_STAT_STAT].starttime;
00857           if(stats[_STAT_STAT].speed < (double)0.0)
00858         stats[_STAT_STAT].speed=(double)0.0;
00859           stats[_STAT_STAT].total_time+=stats[_STAT_STAT].speed;
00860           stats[_STAT_STAT].counter++;
00861           if(stats[_STAT_STAT].speed < stats[_STAT_STAT].best)
00862          stats[_STAT_STAT].best=stats[_STAT_STAT].speed;
00863           if(stats[_STAT_STAT].speed > stats[_STAT_STAT].worst)
00864          stats[_STAT_STAT].worst=stats[_STAT_STAT].speed;
00865         }
00866         junk=chdir("..");
00867       }
00868       junk=chdir("..");
00869     }
00870 }
00871 
00872 void 
00873 file_access(int x)
00874 {
00875     int i,j,k,y;
00876     char buf[100];
00877     stats[_STAT_ACCESS].best=(double)999999.9;
00878     stats[_STAT_ACCESS].worst=(double)0.0;
00879     for(i=0;i<x;i++)
00880     {
00881       sprintf(buf,"fileop_L1_%d",i);
00882       junk=chdir(buf);
00883       for(j=0;j<x;j++)
00884       {
00885         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
00886         junk=chdir(buf);
00887         for(k=0;k<x;k++)
00888         {
00889           sprintf(buf,"fileop_file_%d_%d_%d",i,j,k);
00890           stats[_STAT_ACCESS].starttime=time_so_far();
00891           y=access(buf,W_OK|F_OK);
00892           if(y < 0)
00893           {
00894             printf("access failed\n");
00895         perror("what");
00896             exit(1);
00897           }
00898           stats[_STAT_ACCESS].endtime=time_so_far();
00899           stats[_STAT_ACCESS].speed=stats[_STAT_ACCESS].endtime-stats[_STAT_ACCESS].starttime;
00900           if(stats[_STAT_ACCESS].speed < (double)0.0)
00901         stats[_STAT_ACCESS].speed=(double)0.0;
00902           stats[_STAT_ACCESS].total_time+=stats[_STAT_ACCESS].speed;
00903           stats[_STAT_ACCESS].counter++;
00904           if(stats[_STAT_ACCESS].speed < stats[_STAT_ACCESS].best)
00905          stats[_STAT_ACCESS].best=stats[_STAT_ACCESS].speed;
00906           if(stats[_STAT_ACCESS].speed > stats[_STAT_ACCESS].worst)
00907          stats[_STAT_ACCESS].worst=stats[_STAT_ACCESS].speed;
00908         }
00909         junk=chdir("..");
00910       }
00911       junk=chdir("..");
00912     }
00913 }
00914 
00915 void 
00916 file_chmod(int x)
00917 {
00918     int i,j,k,y;
00919     char buf[100];
00920     stats[_STAT_CHMOD].best=(double)999999.9;
00921     stats[_STAT_CHMOD].worst=(double)0.0;
00922     for(i=0;i<x;i++)
00923     {
00924       sprintf(buf,"fileop_L1_%d",i);
00925       junk=chdir(buf);
00926       for(j=0;j<x;j++)
00927       {
00928         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
00929         junk=chdir(buf);
00930         for(k=0;k<x;k++)
00931         {
00932           sprintf(buf,"fileop_file_%d_%d_%d",i,j,k);
00933           stats[_STAT_CHMOD].starttime=time_so_far();
00934           y=chmod(buf,0666);
00935           if(y < 0)
00936           {
00937             printf("chmod failed\n");
00938         perror("what");
00939             exit(1);
00940           }
00941           stats[_STAT_CHMOD].endtime=time_so_far();
00942           stats[_STAT_CHMOD].speed=stats[_STAT_CHMOD].endtime-stats[_STAT_CHMOD].starttime;
00943           if(stats[_STAT_CHMOD].speed < (double)0.0)
00944         stats[_STAT_CHMOD].speed=(double)0.0;
00945           stats[_STAT_CHMOD].total_time+=stats[_STAT_CHMOD].speed;
00946           stats[_STAT_CHMOD].counter++;
00947           if(stats[_STAT_CHMOD].speed < stats[_STAT_CHMOD].best)
00948          stats[_STAT_CHMOD].best=stats[_STAT_CHMOD].speed;
00949           if(stats[_STAT_CHMOD].speed > stats[_STAT_CHMOD].worst)
00950          stats[_STAT_CHMOD].worst=stats[_STAT_CHMOD].speed;
00951         }
00952         junk=chdir("..");
00953       }
00954       junk=chdir("..");
00955     }
00956 }
00957 
00958 void 
00959 file_readdir(int x)
00960 {
00961     int i,j,ret1;
00962     char buf[100];
00963     DIR *dirbuf;
00964     struct dirent *y;
00965     stats[_STAT_READDIR].best=(double)999999.9;
00966     stats[_STAT_READDIR].worst=(double)0.0;
00967     for(i=0;i<x;i++)
00968     {
00969       sprintf(buf,"fileop_L1_%d",i);
00970       junk=chdir(buf);
00971       for(j=0;j<x;j++)
00972       {
00973         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
00974         junk=chdir(buf);
00975         dirbuf=opendir(".");
00976         if(dirbuf==0)
00977         {
00978         printf("opendir failed\n");
00979         exit(1);
00980         }
00981         stats[_STAT_READDIR].starttime=time_so_far();
00982         y=readdir(dirbuf);
00983         if(y == 0)
00984         {
00985           printf("readdir failed\n");
00986           exit(1);
00987         }
00988         stats[_STAT_READDIR].endtime=time_so_far();
00989         stats[_STAT_READDIR].speed=stats[_STAT_READDIR].endtime-stats[_STAT_READDIR].starttime;
00990           if(stats[_STAT_READDIR].speed < (double)0.0)
00991         stats[_STAT_READDIR].speed=(double)0.0;
00992         stats[_STAT_READDIR].total_time+=stats[_STAT_READDIR].speed;
00993         stats[_STAT_READDIR].counter++;
00994         if(stats[_STAT_READDIR].speed < stats[_STAT_READDIR].best)
00995          stats[_STAT_READDIR].best=stats[_STAT_READDIR].speed;
00996         if(stats[_STAT_READDIR].speed > stats[_STAT_READDIR].worst)
00997          stats[_STAT_READDIR].worst=stats[_STAT_READDIR].speed;
00998         ret1=closedir(dirbuf);
00999         if(ret1 < 0)
01000         {
01001           printf("closedir failed\n");
01002           exit(1);
01003         }
01004         junk=chdir("..");
01005       }
01006       junk=chdir("..");
01007     }
01008 }
01009 
01010 void 
01011 file_link(int x)
01012 {
01013     int i,j,k,y;
01014     char buf[100];
01015     char bufn[100];
01016     stats[_STAT_LINK].best=(double)999999.9;
01017     stats[_STAT_LINK].worst=(double)0.0;
01018     for(i=0;i<x;i++)
01019     {
01020       sprintf(buf,"fileop_L1_%d",i);
01021       junk=chdir(buf);
01022       for(j=0;j<x;j++)
01023       {
01024         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
01025         junk=chdir(buf);
01026         for(k=0;k<x;k++)
01027         {
01028           sprintf(buf,"fileop_file_%d_%d_%d",i,j,k);
01029           sprintf(bufn,"fileop_file_%d_%d_%dL",i,j,k);
01030           stats[_STAT_LINK].starttime=time_so_far();
01031           y=link(buf,bufn);
01032           if(y < 0)
01033           {
01034             printf("Link failed\n");
01035             exit(1);
01036           }
01037           stats[_STAT_LINK].endtime=time_so_far();
01038           stats[_STAT_LINK].speed=stats[_STAT_LINK].endtime-stats[_STAT_LINK].starttime;
01039           if(stats[_STAT_LINK].speed < (double)0.0)
01040         stats[_STAT_LINK].speed=(double)0.0;
01041           stats[_STAT_LINK].total_time+=stats[_STAT_LINK].speed;
01042           stats[_STAT_LINK].counter++;
01043           if(stats[_STAT_LINK].speed < stats[_STAT_LINK].best)
01044          stats[_STAT_LINK].best=stats[_STAT_LINK].speed;
01045           if(stats[_STAT_LINK].speed > stats[_STAT_LINK].worst)
01046          stats[_STAT_LINK].worst=stats[_STAT_LINK].speed;
01047         }
01048         junk=chdir("..");
01049       }
01050       junk=chdir("..");
01051     }
01052 }
01053 
01054 void 
01055 file_unlink(int x)
01056 {
01057     int i,j,k,y;
01058     char buf[100];
01059     char bufn[100];
01060     stats[_STAT_UNLINK].best=(double)999999.9;
01061     stats[_STAT_UNLINK].worst=(double)0.0;
01062     for(i=0;i<x;i++)
01063     {
01064       sprintf(buf,"fileop_L1_%d",i);
01065       junk=chdir(buf);
01066       for(j=0;j<x;j++)
01067       {
01068         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
01069         junk=chdir(buf);
01070         for(k=0;k<x;k++)
01071         {
01072           sprintf(buf,"fileop_file_%d_%d_%d",i,j,k);
01073           sprintf(bufn,"fileop_file_%d_%d_%dL",i,j,k);
01074           stats[_STAT_UNLINK].starttime=time_so_far();
01075           y=unlink(bufn);
01076           if(y < 0)
01077           {
01078             printf("Unlink failed\n");
01079             exit(1);
01080           }
01081           stats[_STAT_UNLINK].endtime=time_so_far();
01082           stats[_STAT_UNLINK].speed=stats[_STAT_UNLINK].endtime-stats[_STAT_UNLINK].starttime;
01083           if(stats[_STAT_UNLINK].speed < (double)0.0)
01084         stats[_STAT_UNLINK].speed=(double)0.0;
01085           stats[_STAT_UNLINK].total_time+=stats[_STAT_UNLINK].speed;
01086           stats[_STAT_UNLINK].counter++;
01087           if(stats[_STAT_UNLINK].speed < stats[_STAT_UNLINK].best)
01088          stats[_STAT_UNLINK].best=stats[_STAT_UNLINK].speed;
01089           if(stats[_STAT_UNLINK].speed > stats[_STAT_UNLINK].worst)
01090          stats[_STAT_UNLINK].worst=stats[_STAT_UNLINK].speed;
01091         }
01092         junk=chdir("..");
01093       }
01094       junk=chdir("..");
01095     }
01096 }
01097 
01098 void
01099 dir_delete(int x)
01100 {
01101     int i,j,k;
01102     char buf[100];
01103     stats[_STAT_DIR_DELETE].best=(double)99999.9;
01104     stats[_STAT_DIR_DELETE].worst=(double)0.00000000;
01105     for(i=0;i<x;i++)
01106     {
01107       sprintf(buf,"fileop_L1_%d",i);
01108       junk=chdir(buf);
01109       for(j=0;j<x;j++)
01110       {
01111         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
01112         junk=chdir(buf);
01113         for(k=0;k<x;k++)
01114         {
01115           sprintf(buf,"fileop_dir_%d_%d_%d",i,j,k);
01116           junk=chdir(buf);
01117           junk=chdir("..");
01118           stats[_STAT_DIR_DELETE].starttime=time_so_far();
01119           rmdir(buf);
01120           stats[_STAT_DIR_DELETE].endtime=time_so_far();
01121           stats[_STAT_DIR_DELETE].speed=stats[_STAT_DIR_DELETE].endtime-stats[_STAT_DIR_DELETE].starttime;
01122           if(stats[_STAT_DIR_DELETE].speed < (double)0.0)
01123         stats[_STAT_DIR_DELETE].speed=(double)0.0;
01124           stats[_STAT_DIR_DELETE].total_time+=stats[_STAT_DIR_DELETE].speed;
01125           stats[_STAT_DIR_DELETE].counter++;
01126           if(stats[_STAT_DIR_DELETE].speed < stats[_STAT_DIR_DELETE].best)
01127          stats[_STAT_DIR_DELETE].best=stats[_STAT_DIR_DELETE].speed;
01128           if(stats[_STAT_DIR_DELETE].speed > stats[_STAT_DIR_DELETE].worst)
01129          stats[_STAT_DIR_DELETE].worst=stats[_STAT_DIR_DELETE].speed;
01130         }
01131         junk=chdir("..");
01132         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
01133         stats[_STAT_DIR_DELETE].starttime=time_so_far();
01134         rmdir(buf);
01135         stats[_STAT_DIR_DELETE].endtime=time_so_far();
01136         stats[_STAT_DIR_DELETE].speed=stats[_STAT_DIR_DELETE].endtime-stats[_STAT_DIR_DELETE].starttime;
01137           if(stats[_STAT_DIR_DELETE].speed < (double)0.0)
01138         stats[_STAT_DIR_DELETE].speed=(double)0.0;
01139         stats[_STAT_DIR_DELETE].total_time+=stats[_STAT_DIR_DELETE].speed;
01140         stats[_STAT_DIR_DELETE].counter++;
01141         if(stats[_STAT_DIR_DELETE].speed < stats[_STAT_DIR_DELETE].best)
01142          stats[_STAT_DIR_DELETE].best=stats[_STAT_DIR_DELETE].speed;
01143         if(stats[_STAT_DIR_DELETE].speed > stats[_STAT_DIR_DELETE].worst)
01144          stats[_STAT_DIR_DELETE].worst=stats[_STAT_DIR_DELETE].speed;
01145       }
01146       junk=chdir("..");
01147       sprintf(buf,"fileop_L1_%d",i);
01148       stats[_STAT_DIR_DELETE].starttime=time_so_far();
01149       rmdir(buf);
01150       stats[_STAT_DIR_DELETE].endtime=time_so_far();
01151       stats[_STAT_DIR_DELETE].speed=stats[_STAT_DIR_DELETE].endtime-stats[_STAT_DIR_DELETE].starttime;
01152       if(stats[_STAT_DIR_DELETE].speed < (double)0.0)
01153         stats[_STAT_DIR_DELETE].speed=(double)0.0;
01154       stats[_STAT_DIR_DELETE].total_time+=stats[_STAT_DIR_DELETE].speed;
01155       stats[_STAT_DIR_DELETE].counter++;
01156       if(stats[_STAT_DIR_DELETE].speed < stats[_STAT_DIR_DELETE].best)
01157          stats[_STAT_DIR_DELETE].best=stats[_STAT_DIR_DELETE].speed;
01158       if(stats[_STAT_DIR_DELETE].speed > stats[_STAT_DIR_DELETE].worst)
01159          stats[_STAT_DIR_DELETE].worst=stats[_STAT_DIR_DELETE].speed;
01160     }
01161 }
01162 
01163 void
01164 file_delete(int x)
01165 {
01166     int i,j,k;
01167     char buf[100];
01168     stats[_STAT_DELETE].best=(double)999999.9;
01169     stats[_STAT_DELETE].worst=(double)0.0;
01170     for(i=0;i<x;i++)
01171     {
01172       sprintf(buf,"fileop_L1_%d",i);
01173       junk=chdir(buf);
01174       for(j=0;j<x;j++)
01175       {
01176         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
01177         junk=chdir(buf);
01178         for(k=0;k<x;k++)
01179         {
01180           sprintf(buf,"fileop_file_%d_%d_%d",i,j,k);
01181           stats[_STAT_DELETE].starttime=time_so_far();
01182           unlink(buf);
01183           stats[_STAT_DELETE].endtime=time_so_far();
01184           stats[_STAT_DELETE].speed=stats[_STAT_DELETE].endtime-stats[_STAT_DELETE].starttime;
01185           if(stats[_STAT_DELETE].speed < (double)0.0)
01186         stats[_STAT_DELETE].speed=(double)0.0;
01187           stats[_STAT_DELETE].total_time+=stats[_STAT_DELETE].speed;
01188           stats[_STAT_DELETE].counter++;
01189           if(stats[_STAT_DELETE].speed < stats[_STAT_DELETE].best)
01190          stats[_STAT_DELETE].best=stats[_STAT_DELETE].speed;
01191           if(stats[_STAT_DELETE].speed > stats[_STAT_DELETE].worst)
01192          stats[_STAT_DELETE].worst=stats[_STAT_DELETE].speed;
01193         }
01194         junk=chdir("..");
01195         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
01196         rmdir(buf);
01197       }
01198       junk=chdir("..");
01199       sprintf(buf,"fileop_L1_%d",i);
01200       rmdir(buf);
01201     }
01202 }
01203 void 
01204 file_read(int x)
01205 {
01206     int i,j,k,y,fd;
01207     char buf[100];
01208     char value;
01209     stats[_STAT_READ].best=(double)99999.9;
01210     stats[_STAT_READ].worst=(double)0.00000000;
01211     stats[_STAT_OPEN].best=(double)99999.9;
01212     stats[_STAT_OPEN].worst=(double)0.00000000;
01213     for(i=0;i<x;i++)
01214     {
01215       sprintf(buf,"fileop_L1_%d",i);
01216       junk=chdir(buf);
01217       for(j=0;j<x;j++)
01218       {
01219         sprintf(buf,"fileop_L1_%d_L2_%d",i,j);
01220         junk=chdir(buf);
01221         for(k=0;k<x;k++)
01222         {
01223           sprintf(buf,"fileop_file_%d_%d_%d",i,j,k);
01224           value=(char)((i^j^k) &0xff);
01225           stats[_STAT_OPEN].starttime=time_so_far();
01226           fd=open(buf,O_RDONLY);
01227           if(fd < 0)
01228           {
01229             printf("Open failed\n");
01230             exit(1);
01231           }
01232           stats[_STAT_OPEN].endtime=time_so_far();
01233           stats[_STAT_OPEN].speed=stats[_STAT_OPEN].endtime-stats[_STAT_OPEN].starttime;
01234           if(stats[_STAT_OPEN].speed < (double)0.0)
01235         stats[_STAT_OPEN].speed=(double)0.0;
01236           stats[_STAT_OPEN].total_time+=stats[_STAT_OPEN].speed;
01237           stats[_STAT_OPEN].counter++;
01238           if(stats[_STAT_OPEN].speed < stats[_STAT_OPEN].best)
01239          stats[_STAT_OPEN].best=stats[_STAT_OPEN].speed;
01240           if(stats[_STAT_OPEN].speed > stats[_STAT_OPEN].worst)
01241          stats[_STAT_OPEN].worst=stats[_STAT_OPEN].speed;
01242 
01243           stats[_STAT_READ].starttime=time_so_far();
01244           y=read(fd,mbuffer,sz);
01245           if(y < 0)
01246           {
01247             printf("Read failed\n");
01248             exit(1);
01249           }
01250           if(validate(mbuffer,sz, value) !=0)
01251         printf("Error: Data Mis-compare\n");;
01252           stats[_STAT_READ].endtime=time_so_far();
01253           close(fd);
01254           stats[_STAT_READ].speed=stats[_STAT_READ].endtime-stats[_STAT_READ].starttime;
01255           if(stats[_STAT_READ].speed < (double)0.0)
01256         stats[_STAT_READ].speed=(double)0.0;
01257           stats[_STAT_READ].total_time+=stats[_STAT_READ].speed;
01258           stats[_STAT_READ].counter++;
01259           if(stats[_STAT_READ].speed < stats[_STAT_READ].best)
01260          stats[_STAT_READ].best=stats[_STAT_READ].speed;
01261           if(stats[_STAT_READ].speed > stats[_STAT_READ].worst)
01262          stats[_STAT_READ].worst=stats[_STAT_READ].speed;
01263         }
01264         junk=chdir("..");
01265       }
01266       junk=chdir("..");
01267     }
01268 }
01269 
01270 /************************************************************************/
01271 /* Time measurement routines. Thanks to Iozone :-)          */
01272 /************************************************************************/
01273 
01274 #ifdef HAVE_ANSIC_C
01275 static double
01276 time_so_far(void)
01277 #else
01278 static double
01279 time_so_far()
01280 #endif
01281 {
01282 #ifdef Windows
01283    LARGE_INTEGER freq,counter;
01284    double wintime,bigcounter;
01285     /* For Windows the time_of_day() is useless. It increments in 55 milli second   */
01286     /* increments. By using the Win32api one can get access to the high performance */
01287     /* measurement interfaces. With this one can get back into the 8 to 9       */
01288     /* microsecond resolution.                          */
01289         QueryPerformanceFrequency(&freq);
01290         QueryPerformanceCounter(&counter);
01291         bigcounter=(double)counter.HighPart *(double)0xffffffff +
01292                 (double)counter.LowPart;
01293         wintime = (double)(bigcounter/(double)freq.LowPart);
01294         return((double)wintime);
01295 #else
01296 #if defined (OSFV4) || defined(OSFV3) || defined(OSFV5)
01297   struct timespec gp;
01298 
01299   if (getclock(TIMEOFDAY, (struct timespec *) &gp) == -1)
01300     perror("getclock");
01301   return (( (double) (gp.tv_sec)) +
01302     ( ((float)(gp.tv_nsec)) * 0.000000001 ));
01303 #else
01304   struct timeval tp;
01305 
01306   if (gettimeofday(&tp, (struct timezone *) NULL) == -1)
01307     perror("gettimeofday");
01308   return ((double) (tp.tv_sec)) +
01309     (((double) tp.tv_usec) * 0.000001 );
01310 #endif
01311 #endif
01312 }
01313 
01314 void
01315 splash(void)
01316 {
01317     printf("\n");
01318     printf("     --------------------------------------\n");
01319     printf("     |              Fileop                | \n");
01320     printf("     | %s          | \n",version);
01321     printf("     |                                    | \n");
01322     printf("     |                by                  |\n");
01323     printf("     |                                    | \n");
01324     printf("     |             Don Capps              |\n");
01325     printf("     --------------------------------------\n");
01326     printf("\n");
01327 }
01328 
01329 void 
01330 usage(void)
01331 {
01332   splash();
01333   printf("     fileop [-f X ]|[-l # -u #] [-s Y] [-e] [-b] [-w] [-d <dir>] [-t] [-v] [-h]\n");
01334   printf("\n");
01335   printf("     -f #      Force factor. X^3 files will be created and removed.\n");
01336   printf("     -l #      Lower limit on the value of the Force factor.\n");
01337   printf("     -u #      Upper limit on the value of the Force factor.\n");
01338   printf("     -s #      Optional. Sets filesize for the create/write. May use suffix 'K' or 'M'.\n");
01339   printf("     -e        Excel importable format.\n");
01340   printf("     -b        Output best case results.\n");
01341   printf("     -i #      Increment force factor by this increment.\n");
01342   printf("     -w        Output worst case results.\n");
01343   printf("     -d <dir>  Specify starting directory.\n");
01344   printf("     -U <dir>  Mount point to remount between tests.\n");
01345   printf("     -t        Verbose output option.\n");
01346   printf("     -v        Version information.\n");
01347   printf("     -h        Help text.\n");
01348   printf("\n");
01349   printf("     The structure of the file tree is:\n");
01350   printf("     X number of Level 1 directories, with X number of\n");
01351   printf("     level 2 directories, with X number of files in each\n");
01352   printf("     of the level 2 directories.\n");
01353   printf("\n");
01354   printf("     Example:  fileop 2\n");
01355   printf("\n");
01356   printf("             dir_1                        dir_2\n");
01357   printf("            /     \\                      /     \\ \n");
01358   printf("      sdir_1       sdir_2          sdir_1       sdir_2\n");
01359   printf("      /     \\     /     \\          /     \\      /     \\ \n");
01360   printf("   file_1 file_2 file_1 file_2   file_1 file_2 file_1 file_2\n");
01361   printf("\n");
01362   printf("   Each file will be created, and then Y bytes is written to the file.\n");
01363   printf("\n");
01364 }
01365 void
01366 clear_stats()
01367 {
01368     int i;
01369     for(i=0;i<_NUM_STATS;i++)
01370         bzero((char *)&stats[i],sizeof(struct stat_struct));
01371 }
01372 int
01373 validate(char *buffer, int size, char value)
01374 {
01375     register int i;
01376     register char *cp;
01377     register int size1;
01378     register char v1;
01379     v1=value;
01380     cp = buffer;
01381     size1=size;
01382     for(i=0;i<size;i++)
01383     {
01384         if(*cp++ != v1)
01385             return(1);
01386     }
01387     return(0);
01388 }
01389 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines