Пример #1
0
double nbio_result(void)
{
	int i;
	double total = 0;
	for (i=0;i<nprocs;i++) {
		total += children[i].bytes - children[i].warmup_bytes;
	}
	return 1.0e-6 * total / timeval_elapsed2(&tv_start, &tv_end);
}
Пример #2
0
static void sig_alarm(int sig)
{
	double total_bytes = 0;
	int total_lines = 0;
	int i;
	int nclients = options.nprocs * options.clients_per_process;
	int in_warmup = 0;
	double t;
	static int in_cleanup;
	double latency;
	struct timeval tnow;
	int num_active = 0;
	int num_finished = 0;
	(void)sig;

	tnow = timeval_current();

	for (i=0;i<nclients;i++) {
		total_bytes += children[i].bytes - children[i].bytes_done_warmup;
		if (children[i].bytes == 0 && options.warmup == -1) {
			in_warmup = 1;
		} else {
			num_active++;
		}
		total_lines += children[i].line;
		if (children[i].cleanup_finished) {
			num_finished++;
		}
	}

	t = timeval_elapsed(&tv_start);

	if (!in_warmup && options.warmup>0 && t > options.warmup) {
		tv_start = tnow;
		options.warmup = 0;
		for (i=0;i<nclients;i++) {
			children[i].bytes_done_warmup = children[i].bytes;
			children[i].worst_latency = 0;
			memset(&children[i].ops, 0, sizeof(children[i].ops));
		}
		goto next;
	}
	if (t < options.warmup) {
		in_warmup = 1;
	} else if (!in_warmup && !in_cleanup && t > options.timelimit) {
		for (i=0;i<nclients;i++) {
			children[i].done = 1;
		}
		tv_end = tnow;
		in_cleanup = 1;
	}
	if (t < 1) {
		goto next;
	}

	latency = 0;
	if (!in_cleanup) {
		for (i=0;i<nclients;i++) {
			latency = MAX(children[i].max_latency, latency);
			latency = MAX(latency, timeval_elapsed2(&children[i].lasttime, &tnow));
			children[i].max_latency = 0;
			if (latency > children[i].worst_latency) {
				children[i].worst_latency = latency;
			}
		}
	}

        if (in_warmup) {
		if (options.machine_readable) {
                    printf("@W@%d@%d@%.2f@%u@%.03f@\n", 
                       num_active, total_lines/nclients, 
			   1.0e-6 * total_bytes / t, (int)t, latency*1000);
		} else {
                    printf("%4d  %8d  %7.2f MB/sec  warmup %3.0f sec  latency %.03f ms\n", 
                       num_active, total_lines/nclients, 
			   1.0e-6 * total_bytes / t, t, latency*1000);
		}
        } else if (in_cleanup) {
		if (options.machine_readable) {
                    printf("@C@%d@%d@%.2f@%u@%.03f@\n", 
                       num_active, total_lines/nclients, 
			   1.0e-6 * total_bytes / t, (int)t, latency*1000);
		} else {
                    printf("%4d  cleanup %3.0f sec\n", nclients - num_finished, t);
		}
        } else {
		if (options.machine_readable) {
                    printf("@R@%d@%d@%.2f@%u@%.03f@\n", 
                       num_active, total_lines/nclients, 
			   1.0e-6 * total_bytes / t, (int)t, latency*1000);
		} else {
                    printf("%4d  %8d  %7.2f MB/sec  execute %3.0f sec  latency %.03f ms\n", 
                       nclients, total_lines/nclients, 
                       1.0e-6 * total_bytes / t, t, latency*1000);
	  	       throughput = 1.0e-6 * total_bytes / t;
		}
        }

	fflush(stdout);
next:
	signal(SIGALRM, sig_alarm);
	alarm(PRINT_FREQ);
}