add one more cycle
authorteodor <teodor>
Fri, 11 Feb 2005 13:22:20 +0000 (13:22 +0000)
committerteodor <teodor>
Fri, 11 Feb 2005 13:22:20 +0000 (13:22 +0000)
memtest.c

index 6f1aa09..a4536d5 100644 (file)
--- a/memtest.c
+++ b/memtest.c
@@ -41,7 +41,7 @@ static void
 usage() {
        puts(
        "Usage:\n"
-       "memtest [-c COUNT [-t [-D]] [-s MAXSIZE]]\n"
+       "memtest [-c COUNT [-t [-D]] [-s MAXSIZE] [-C COUNTCOUNT]]\n"
        );
        exit(1);
 }
@@ -54,16 +54,19 @@ int
 main(int argn, char *argv[]) {
        MemoryContext   *base, *child;
        int i, SZ=32;
-       int count=0, iscntx=0, flags=0;
+       int count=0, iscntx=0, flags=0,  COUNT=1;
 
        opentlog(TL_OPEN_STDERR,TL_DEBUG, NULL);
        opterr=0;
 
-       while((i=getopt(argn,argv,"s:Dc:ht")) != EOF) {
+       while((i=getopt(argn,argv,"s:Dc:htC:")) != EOF) {
                switch(i) {
                        case 's':
                                SZ=atoi(optarg);
                                break;
+                       case 'C':
+                               COUNT=atoi(optarg);
+                               break;
                        case 'c':
                                count=atoi(optarg);
                                break;
@@ -137,6 +140,7 @@ main(int argn, char *argv[]) {
                srandom(1);
                if ( iscntx ) {
                        gettimeofday(&begin, NULL);
+                       while(COUNT-- > 0) {
                        base = allocMemoryContext(NULL, flags);
                        for(i=0;i<count;i++) {
                                ptr = mcalloc(base, 1+random()%SZ );
@@ -162,11 +166,13 @@ main(int argn, char *argv[]) {
        
                        }
                        freeMemoryContext(base);
+                       }
                        printf("MC elapsed: %f sec\n", elapsedtime(&begin));
 
                } else {
                        char **all, **allptr;
                        gettimeofday(&begin, NULL);
+                       while(COUNT-- > 0) {
                        allptr=all=malloc(sizeof(char*)*count*2);
                        if ( !all )
                                tlog(TL_CRIT|TL_EXIT,"No memory");
@@ -200,6 +206,7 @@ main(int argn, char *argv[]) {
                                allptr++;
                        }
                        free(all);
+                       }
                        printf("Malloc elapsed: %f sec\n", elapsedtime(&begin));
                }