Exemple #1
0
int main(int argc, char *argv[])
{
	int i;
	struct timespec ts;

	/* Parse command line */
	for (i = 1; i < argc; i++) {
		if (!strcmp(argv[i], "-h")) {
			usage(argv[0]);
			return 0;
		}
	}
	for (i = 1; i < argc; i++) {
		if (!strcmp(argv[i], "-l")) {
			NEXT_ARG(i);
			l = atoi(argv[i]);
		} else if (!strcmp(argv[i], "-a")) {
			NEXT_ARG(i);
			if (!strcasecmp(argv[i], "SHA1"))
				algo = TA_SHA_SHA1;
			else if (!strcasecmp(argv[i], "SHA224"))
				algo = TA_SHA_SHA224;
			else if (!strcasecmp(argv[i], "SHA256"))
				algo = TA_SHA_SHA256;
			else if (!strcasecmp(argv[i], "SHA384"))
				algo = TA_SHA_SHA384;
			else if (!strcasecmp(argv[i], "SHA512"))
				algo = TA_SHA_SHA512;
			else {
				fprintf(stderr, "%s, invalid algorithm\n",
					argv[0]);
				usage(argv[0]);
				return 1;
			}
		} else if (!strcmp(argv[i], "-n")) {
			NEXT_ARG(i);
			n = atoi(argv[i]);
		} else if (!strcmp(argv[i], "-r")) {
			random_in = 1;
		} else if (!strcmp(argv[i], "-s")) {
			NEXT_ARG(i);
			size = atoi(argv[i]);
		} else if (!strcmp(argv[i], "-u")) {
			offset = 1;
		} else if (!strcmp(argv[i], "-v")) {
			verbosity++;
		} else if (!strcmp(argv[i], "-w")) {
			NEXT_ARG(i);
			warmup = atoi(argv[i]);
		} else {
			fprintf(stderr, "%s: invalid argument: %s\n",
				argv[0], argv[i]);
			usage(argv[0]);
			return 1;
		}
	}

	vverbose("sha-perf version %s\n", TO_STR(VERSION));
	if (clock_getres(CLOCK_MONOTONIC, &ts) < 0) {
		perror("clock_getres");
		return 1;
	}
	vverbose("Clock resolution is %lu ns\n", ts.tv_sec*1000000000 +
		ts.tv_nsec);

	open_ta();
	prepare_op();
	run_test(size, n, l);

	return 0;
}
int main(int argc, char *argv[]) 
{
	int i = 0;
	int *key;
	record *value;
	filedata_t *fd;
	final_data_t op_results;
	final_data_t op_results0;
	final_data_t op_results2;
	final_data_t op_results3;
	final_data_t op_results4;
	final_data_t op_results5;
	final_data_t op_results6;
	final_data_t op_results7;

	struct timeval starttime,endtime;
	char * fname, * op_num_str;
	int op_num;

	struct timeval begin_total, end_total;


	// Make sure a filename is specified
	if (argv[1] == NULL)
	{
		printf("USAGE: %s <filename> [ # of operator to use (1:sel 2:prj 3:srt 4:prt 5:agg) ]\n", argv[0]);
		exit(1);
	}

	fname = argv[1];
	op_num_str = argv[2];

	// Get the number of operator to run
	CHECK_ERROR((op_num = (op_num_str == NULL) ? 10 : atoi(op_num_str)) < 0);



	fd=load_op (fname, sizeof(record));	
		//printLoads(fd);
	
	if ((op_num  != 6) && (op_num != 0)){
		prepare_op(fd, &op_results, 0);
		dprintf("\nop_results length  %d:\n", op_results.length);
	}
	get_time (&begin_total);

	switch(op_num){
		case 0:
			prepare_op(fd, &op_results0, 1);

			break;
		case 1:
			select_op(&op_results, cmp12, &op_results2, 1);
				print_sel(op_results2);
			break;
		case 2:
			project_op(&op_results, prj5, &op_results3, 1);
				print_prj(op_results3);
			break;
		case 3:
			sort_op(&op_results, stringcmp, key_ptr, keysize, &op_results4, 1);
				print_srt(op_results4);
			break;
		case 4:
			partition_op(&op_results, hsh_prt, &op_results5, 1);
				print_prt(op_results5);

			//	partition_2op(&op_results, prt, &op_results5, 0);
			break;
		case 5:
			aggregate_op(&op_results, aggr, key_ptr, keysize, &op_results6, 1);
				printAggr(op_results6);
			break;
		case 6:
			select_op_old(fd,cmp12, &op_results7, 1);
				print_sel(op_results7);
			break;
		default:
			printf("No operator selected\n");
			break;
	}

	get_time (&end_total);
	unload_op(fd);


#ifdef TIMING
	fprintf (stderr, "\n\nOverall time: %u\n\n\n", time_diff (&end_total, &begin_total));
#endif
	return 1;
}