Ejemplo n.º 1
0
int _CRTAPI1 main(
     int argc,
     char *argv[]
)
{
ITYPE           nbytes;
ITYPE           stride;
ITYPE           iters;
char           *region;

    if ((argc > 1) && (strcmp(argv[1], "-v") == 0)) {
       fprintf(stderr, "This is memtest version %s.\n", version_string);
        exit(1);
    }
    if (argc < 3)
    usage(argv[0]);
    mach_name = argv[1];
    iters = arg_to_int(argv[2]);
    if (argc < 4) {
        max_mem = DEF_MAXMEM;
    } else {
        max_mem = arg_to_int(argv[3]);
    }
    region = (char *) malloc(max_mem+(128*1024));
    region = (char *) ((((long) region) + (128*1024-1)) & ~((128*1024)-1));
    if (region == NULL) {
        perror("malloc failed");
        exit(1);
    }
    printf("  %8s", "");
    printf("%8s", "");
    for (nbytes = MINMEM; nbytes <= max_mem; nbytes += nbytes) {
        if (nbytes >= (1024 * 1024))
            printf("%4dm", nbytes / (1024 * 1024));
        else if (nbytes >= 1024)
            printf("%4dk", nbytes / 1024);
        else
            printf("%5d", nbytes);
    }
    printf("\n");
    for (stride = MINSTRIDE; stride <= MAXSTRIDE; stride += stride) {
        printf("L %-8s", mach_name);
        if (stride >= (1024 * 1024))
            printf("%7dm", stride / (1024 * 1024));
        else if (stride >= 1024)
            printf("%7dk", stride / 1024);
        else
            printf("%8d", stride);
        for (nbytes = MINMEM; nbytes <= max_mem; nbytes += nbytes) {
            double ns_ref = bash(region, nbytes, stride, iters);
            printf("%5.0f", ns_ref);
            fflush(stdout);
        }
        printf("\n");
    }
    exit(0);
    return 0;
}
Ejemplo n.º 2
0
int main(int argc, char* argv[])
{
	/* check arguments */
	while(1) {
		int c = getopt(argc, argv, "-ifrhv::o:");
		if(c == -1) break;

		switch(c) {
			case 'i': flags |= FLAG_INTERACT; break;
			case 'f': flags |= FLAG_FORCE; break;
			case 'r': flags |= FLAG_RECURSIVE; break;

			case 'h': help(); exit(0);

			case 'v': verbose = arg_to_int(optarg, 0, 10, 5, "v"); break;
			case 'o': out_fname = optarg; break;
			case 1: in_fname = optarg; break;

			#ifdef DEBUG
			default:
				printf("Option '%c' (%d) with '%s'\n", c, c, optarg);
			#endif
		}
	}

	#ifdef DEBUG
		printf("optind at %d; argv[optind] = '%s'\n", optind, argv[optind]);
	#endif

	/* print out what we got */
	if(flags & FLAG_INTERACT) printf("in interactive mode\n");
	else printf("not in interactive mode\n");
	if(flags & FLAG_FORCE) printf("in force mode\n");
	else printf("not in force mode\n");
	if(flags & FLAG_RECURSIVE) printf("in recursive mode\n");
	else printf("not in recursive mode\n");
	printf("verbosity level: %d\n", verbose);
	if(in_fname) printf("input filename: %s\n", in_fname);
	else printf("no input filename\n");
	if(out_fname) printf("output filename: %s\n", out_fname);
	else printf("no output filename\n");

	return 0;
}