コード例 #1
0
int main (int argc, char *argv[])
{
	unsigned	threads = 2;

	Option.numthreads = 2;
	punyopt(argc, argv, myopt, "k:");
	Loops   = Option.iterations;
	threads = Option.numthreads;
	if (!threads) {
		fatal("Must have at least one thread");
	}
	if (threads >= Num_locks) {
		fatal("Must have at least one more locks(%ld) than threads(%d)",
			Num_locks, threads);
	}
	init_locks(Num_locks);

#if MUTEX
	printf("pthread mutex\n");
#elif SPIN
	printf("raw spinlock\n");
#elif TSPIN
	printf("pthread spinlock\n");
#elif GLOBAL
	printf("global variable\n");
#else
	printf("Empty test\n");
#endif

	start_threads(threads);

	return 0;
}
コード例 #2
0
ファイル: fcntl.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	pid_t	pid;
	int	rc;

	punyopt(argc, argv, NULL, NULL);

	rc = pipe(Command);
	if (rc == -1) {
		perror("Command pipe");
	}
	rc = pipe(Response);
	if (rc == -1) {
		perror("Response pipe");
	}

	pid = fork();
	if (pid == -1) {
		perror("fork");
		return 1;
	}
	if (pid) {
		parent(Option.file, Option.iterations);
	} else {
		child(Option.file, Option.iterations);
	}
	return 0;
}
コード例 #3
0
ファイル: ucreate.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	char		*name;
	int		fd;
	int		rc;
	unsigned	i;
	unsigned	n;
	u64		l;

	punyopt(argc, argv, NULL, NULL);
	n = Option.iterations;
	name = Option.file;
	for (l = 0; l < Option.loops; l++) {
		startTimer();
		for (i = 0; i < n; ++i) {
			fd = open(name, O_RDWR | O_CREAT | O_TRUNC, 0666);
			if (fd == -1) {
				perror("open");
				exit(1);
			}
			close(fd);
			rc = unlink(name);
			if (rc == -1) {
				perror("unlink");
				exit(1);
			}
		}
		stopTimer();
		prTimer();
		printf("\n");
	}
	return 0;
}
コード例 #4
0
ファイル: ugetpid.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	unsigned	i;
	unsigned	n;
	pid_t		pid;
	u64		l;

	punyopt(argc, argv, NULL, NULL);
	n = Option.iterations;
	for (l = 0; l < Option.loops; l++) {
		startTimer();
		for (i = 0; i < n; ++i) {
			pid = getpid();
			if (!pid) {
				fprintf(stderr, "getpid is zero\n");
				exit(1);
			}
		}
		stopTimer();
		printf("n=%d ", n);
		prTimer();
		printf("\n");
	}
	return 0;
}
コード例 #5
0
ファイル: uwritefiles.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	char	*directory = "";
	char	name[256];
	unint	i, j;
	unint	n = 1000;
	u64	size = (1<<20);

	punyopt(argc, argv, NULL, NULL);
	directory = Option.dir;
	size = Option.file_size;
	n = Option.iterations;
	for (i = 0; i < BUF_SIZE; i++)
	{
		Buf[i] = random();
	}
	mkdir(directory, 0777);
	chdirq(directory);
	for (j = 0; j < Option.loops; j++) {
		sprintf(name, "dir_%ld", j);
		mkdirq(name);
		chdirq(name);
		startTimer();
		for (i = 0; i < n; i++) {
			sprintf(name, "file_%ld", i);
			write_test(name, size);
		}
		stopTimer();
		prTimer();
		printf(" size=%lld n=%ld\n", size, n);
		if (chdir("..")) perror("chdir ..");
	}
	return 0;
}
コード例 #6
0
ファイル: events.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	punyopt(argc, argv, NULL, NULL);
	start_threads(Option.numthreads);
	print_history(&History, ARRAY_SIZE(Event_name), Event_name);
	return 0;
}
コード例 #7
0
ファイル: main.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	int i;

	Option.file_size = Local_option.size_big_file;
	Option.dir = ".";
	punyopt(argc, argv, myopt, "b:forsv");
	Local_option.size_big_file = Option.file_size;

	if (Local_option.size_big_file < 40000) {
		PrError("Size of big file, %lld, should be greater than 40K",
			Local_option.size_big_file);
		return 2;
	}
	if (Local_option.size_big_file < (1LL << 32)) {
		fprintf(stderr, "Size of big file only 0x%llx\n",
			Local_option.size_big_file);
	}
	if (argc == optind) {
		all_tests(Option.dir);
	} else for (i = optind; i < argc; i++) {
		all_tests(argv[i]);
	}
	if (Option.print) DumpRecords();
	return 0;
}
コード例 #8
0
ファイル: ureaddir.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	struct dirent	*de;
	DIR		*dir;
	unsigned	i, j;
	unsigned	n;
	u64		l;

	punyopt(argc, argv, myopt, "k:");
	n = Option.iterations;
	mkdir(Option.dir, 0777);
	chdirq(Option.dir);
	create_files(Numfiles);
	for (l = 0; l < Option.loops; l++) {
		startTimer();
		for (j = 0; j < n; ++j) {
			dir = opendir(".");
			if (!dir) {
				perror(".");
				exit(1);
			}
			for (i = 0;; ++i) {
				de = readdir(dir);
				if (!de) break;
			}
			closedir(dir);
		}
		stopTimer();
		prTimer();
		printf(" n=%d l=%lld\n", n, l);
	}
	return 0;
}
コード例 #9
0
ファイル: utime.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	struct stat	sb;
	struct utimbuf	utbuf;
	char	*name;
	int	rc;

	punyopt(argc, argv, NULL, NULL);
	name = Option.file;
	rc = stat(name, &sb);
	if (rc == -1) {
		perror(name);
		exit(1);
	}
	prStatNice( &sb); printf(" %s\n", name);
	utbuf.actime = sb.st_atime + 100;
	//utbuf.modtime = sb.st_mtime + 200;
	utbuf.modtime = sb.st_mtime;
	rc = utime(name, &utbuf);
	if (rc == -1)
	{
		perror("utime");
		exit(2);
	}
	rc = stat(name, &sb);
	if (rc == -1) {
		perror(name);
		exit(1);
	}
	prStatNice( &sb); printf(" %s\n", name);
	return 0;
}
コード例 #10
0
ファイル: urename.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	int		rc;
	unsigned	i;
	unsigned	n = 1000;
	u64		l;

	punyopt(argc, argv, NULL, NULL);
	n = Option.iterations;
	make_names(Option.file);
	for (l = 0; l < Option.loops; l++) {
		startTimer();
		for (i = 0; i < n; ++i) {
			rc = rename(NameA, NameB);
			if (rc == -1) {
				perror("renameAB");
				exit(1);
			}
			rc = rename(NameB, NameC);
			if (rc == -1) {
				perror("renameBC");
				exit(1);
			}
			rc = rename(NameC, NameA);
			if (rc == -1) {
				perror("renameCA");
				exit(1);
			}
		}
		stopTimer();
		prTimer();
		printf("\n");
	}
	return 0;
}
コード例 #11
0
ファイル: tsync.c プロジェクト: taysom/tau
int main(int argc, char *argv[])
{
	phasefn_t fn;

	punyopt(argc, argv, myopt, "p:");
	fn = find_phase(PhaseName);
	if (fn)
		fn();	
	return 0;
}
コード例 #12
0
ファイル: memcpy.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	Option.iterations = 2;
	Option.loops = 4;
	Option.file_size = (1<<24);
	Option.numthreads = 1;
	punyopt(argc, argv, myopt, "bmnu");
	StartThreads();
	return 0;
}
コード例 #13
0
ファイル: rename.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	int	rc;

	punyopt(argc, argv, NULL, NULL);
	rc = rename(Option.file, Option.dest);
	if (rc == -1) {
		fatal("rename %s to %s:", Option.file, Option.dir);
	}
	return 0;
}
コード例 #14
0
ファイル: noatime.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	char		*file;
	int		fd;

	punyopt(argc, argv, NULL, NULL);
	file = Option.file;

	fd = openq(file, O_RDWR | O_CREAT);
	mystat(fd, "after open/create");
	sleep(2);
	writeq(fd, Write, sizeof(Write));
	mystat(fd, "after write");
	closeq(fd);


	sleep(2);
	fd = openq(file, O_RDWR | O_NOATIME);
	sleep(2);
	mystat(fd, "after open noatime");
	sleep(2);
	mystat(fd, "before read noatime");
	readq(fd, Read, sizeof(Read));
	mystat(fd, "after read noatime");
	closeq(fd);

	sleep(2);
	fd = openq(file, O_RDWR);
	mystat(fd, "after open rdwr");
	sleep(2);
	mystat(fd, "before read");
	readq(fd, Read, sizeof(Read));
	mystat(fd, "after read");
	closeq(fd);

	sleep(2);
	fd = openq(file, O_RDWR);
	mystat(fd, "after open");
	sleep(2);
	fsetxattr(fd, "noatime", Test, sizeof(Test), 0);
	mystat(fd, "after setxattr");
	sleep(2);
	mystat(fd, "before read");
	readq(fd, Read, sizeof(Read));
	mystat(fd, "after read");
	sleep(2);
	fgetxattr(fd, "noatime", Read, sizeof(Read));
	mystat(fd, "after getxattr");
	closeq(fd);

	return 0;
}
コード例 #15
0
ファイル: symlink.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	int	rc;
	char	*oldpath;
	char	*newpath;

	punyopt(argc, argv, NULL, NULL);
	newpath = Option.dest;
	oldpath = gen_name(Option.name_size);
	rc = symlink(oldpath, newpath);
	if (rc) eprintf("symlink %s -> %s failed:", oldpath, newpath);

	return 0;
}
コード例 #16
0
ファイル: telldir.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	char	*dir;
	int	rc;

	punyopt(argc, argv, NULL, NULL);
	dir = Option.dir;
	rc = chdir(dir);
	if (rc) {
		perror(dir);
		exit(2);
	}
	build_dir(300000);
	tst_telldir();
	return 0;
}
コード例 #17
0
ファイル: fill.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	pthread_t	timer_thread;
	pthread_t	writer_thread;
	int	rc;

	punyopt(argc, argv, myopt, "k");
	rc = pthread_create(&timer_thread, NULL, timer, NULL);
	if (rc) fatal("timer thread:");
	rc = pthread_create(&writer_thread, NULL, writer, NULL);
	if (rc) fatal("writer thread:");

	pthread_join(writer_thread, NULL);
	pthread_join(timer_thread, NULL);

	return 0;
}
コード例 #18
0
ファイル: listxattr.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	ssize_t	size;

	punyopt(argc, argv, NULL, NULL);

	size = listxattr(Option.file, List, sizeof(List));
	if (size == -1) {
		perror(Option.file);
		exit(2);
	}

	printf("xattrs for %s:\n", Option.file);
	dump_list(List, size);

	return 0;
}
コード例 #19
0
ファイル: unlink.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	int		rc;

	punyopt(argc, argv, NULL, NULL);
	if (argc != 2) {
		fprintf(stderr, "unlink file\n");
		return 1;
	}
	rc = unlink(Option.file);
	if (rc == -1) {
		rc = errno;
		fprintf(stderr, "unlink %s: %s\n",
				Option.file, strerror(errno));
		return rc;
	}
	return 0;
}
コード例 #20
0
ファイル: hammer.c プロジェクト: taysom/tau
int main(int argc, char *argv[])
{
	pthread_t timer_thread;
	pthread_t writer_thread;
	int rc;

	Option.file_size = FILE_SIZE_MEG;
	Option.sleep_secs = 1;

	punyopt(argc, argv, myopt, "k");
	rc = pthread_create(&timer_thread, NULL, timer, NULL);
	if (rc) fatal("timer thread:");
	rc = pthread_create(&writer_thread, NULL, writer, NULL);
	if (rc) fatal("writer thread:");

	pthread_join(writer_thread, NULL);
	pthread_join(timer_thread, NULL);

	return 0;
}
コード例 #21
0
ファイル: uread.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	u8		*buf;
	int		fd;
	ssize_t		haveRead;
	size_t		toRead;
	unsigned	i;
	unsigned	bufsize;
	unsigned	n;
	u64		size;
	u64		rest;
	u64		l;

	drop_caches();
	Option.file_size = 0;
	Option.iterations = 1;
	Option.loops = 1;
	punyopt(argc, argv, myopt, "b:");
	n = Option.iterations;
	bufsize = 1 << Bufsize_log2;
	buf = emalloc(bufsize);
	size = Option.file_size;
	if (!size) {
		size = memtotal() / FRACTION_OF_MEMORY;
	}
	if (Hog_memory) {
		hog_leave_memory(size / FRACTION_OF_FILE_SIZE);
	}
	fd = open(Option.file, O_RDWR | O_CREAT | O_TRUNC, 0666);
	fill_file(fd, size);
	for (l = 0; l < Option.loops; l++) {
		startTimer();
		for (i = 0; i < n; ++i) {
			for (rest = size; rest; rest -= haveRead) {
				if (rest > bufsize) {
					toRead = bufsize;
				} else {
					toRead = rest;
				}
				haveRead = read(fd, buf, toRead);
				if (haveRead != toRead) {
					if (haveRead == -1) {
						perror("read");
						exit(1);
					}
					fprintf(stderr,
						"toRead=%llu != haveRead=%lld\n",
						(u64)toRead, (s64)haveRead);
					exit(1);
				}
			}
			lseek(fd, 0, 0);
		}
		stopTimer();
		printf("size=%lld n=%d ", size, n);
		prTimer();

		printf("\t%6.4g MiB/s\n",
			(double)(n * size) / get_avg() / MEBI);
	}
	close(fd);
	unlink(Option.file);
	return 0;
}
コード例 #22
0
ファイル: mwrite.c プロジェクト: taysom/tau
int main (int argc, char *argv[])
{
	u8		*buf;
	int		fd;
	ssize_t		written;
	size_t		toWrite;
	unsigned	i;
	unsigned	bufsize;
	unsigned	n;
	u64		size;
	u64		rest;
	u64		l;

	Option.file_size = 8ULL * GIBI;
	Option.iterations = 1;
	Option.loops = 1;
	punyopt(argc, argv, myopt, "b:");
	n = Option.iterations;
	bufsize = 1 << Bufsize_log2;
	buf = emalloc(bufsize);
	size = Option.file_size;

	buf = emalloc(bufsize);
	for (i = 0; i < bufsize; ++i) {
		buf[i] = random();
	}
	for (l = 0; l < Option.loops; l++) {
		startTimer();
		for (i = 0; i < n; i++) {
			/* Because eCryptfs has to decrypt a page before
			 * overwriting it, recreating the file on each
			 * iteration gives a more realistic value.
			 */
			fd = open(Option.file,
				O_RDWR | O_CREAT | O_TRUNC, 0666);
			if (fd == -1) fatal("open %s:", Option.file);
			for (rest = size; rest; rest -= written) {
				if (rest > bufsize) {
					toWrite = bufsize;
				} else {
					toWrite = rest;
				}
				written = write(fd, buf, toWrite);
				if (written != toWrite) {
					if (written == -1) {
						perror("write");
						exit(1);
					}
					fprintf(stderr,
						"toWrite=%lu != written=%ld\n",
						(unint)toWrite, (snint)written);
					exit(1);
				}
				/* Make next buffer unique */
				buf[urand(bufsize)] = random();
			}
			fsync(fd);
			close(fd);
		}
		stopTimer();
		printf("size=%lld n=%d ", size, n);
		prTimer();

		printf("\t%6.4g MiB/s",
			(double)(n * size) / get_avg() / MEBI);

		printf("\n");
	}
	unlink(Option.file);
	return 0;
}