/* * Function: output_results * Purpose: Print information about the time & bandwidth for a given * minmax & # of iterations. * Return: Nothing * Programmer: Quincey Koziol, 9. May 2002 * Modifications: */ static void output_results(const struct options *opts, const char *name, minmax *table, int table_size,off_t data_size) { minmax total_mm; accumulate_minmax_stuff(table, table_size, &total_mm); print_indent(3); output_report("%s (%d iteration(s)):\n", name,table_size); /* Note: The maximum throughput uses the minimum amount of time & vice versa */ print_indent(4); output_report("Maximum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.min)); if(opts->print_times) output_report(" (%7.3f s)\n", total_mm.min); else output_report("\n"); print_indent(4); output_report("Average Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.sum / total_mm.num)); if(opts->print_times) output_report(" (%7.3f s)\n", (total_mm.sum / total_mm.num)); else output_report("\n"); print_indent(4); output_report("Minimum Throughput: %6.2f MB/s", MB_PER_SEC(data_size,total_mm.max)); if(opts->print_times) output_report(" (%7.3f s)\n", total_mm.max); else output_report("\n"); }
static void do_write_test(unsigned long file_size, unsigned long min_buf_size, unsigned long max_buf_size) { uLongf src_len, total_len; struct timeval timer_start, timer_stop; double total_time; Bytef *src; for (src_len = min_buf_size; src_len <= max_buf_size; src_len <<= 1) { register unsigned long i, iters; iters = file_size / src_len; src = (Bytef *)HDcalloc(1, sizeof(Bytef) * src_len); if (!src) { cleanup(); error("out of memory"); } compression_time = 0.0; if (random_test) fill_with_random_data(src, src_len); HDfprintf(stdout, "Buffer size == "); if (src_len >= ONE_KB && (src_len % ONE_KB) == 0) { if (src_len >= ONE_MB && (src_len % ONE_MB) == 0) { HDfprintf(stdout, "%ldMB", src_len / ONE_MB); } else { HDfprintf(stdout, "%ldKB", src_len / ONE_KB); } } else { HDfprintf(stdout, "%ld", src_len); } HDfprintf(stdout, "\n"); /* do uncompressed data write */ HDgettimeofday(&timer_start, NULL); output = HDopen(filename, O_RDWR | O_CREAT, S_IRWXU); if (output == -1) error(HDstrerror(errno)); for (i = 0; i <= iters; ++i) { Bytef *s_ptr = src; uLong s_len = src_len; /* loop to make sure we write everything out that we want to write */ for (;;) { ssize_t rc = HDwrite(output, s_ptr, s_len); if (rc == -1) error(HDstrerror(errno)); if (rc == (ssize_t)s_len) break; s_len -= rc; s_ptr += rc; } } HDclose(output); HDgettimeofday(&timer_stop, NULL); total_time = ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / MICROSECOND) - ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); HDfprintf(stdout, "\tUncompressed Write Time: %.2fs\n", total_time); HDfprintf(stdout, "\tUncompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); HDunlink(filename); /* do compressed data write */ output = HDopen(filename, O_RDWR | O_CREAT, S_IRWXU); if (output == -1) error(HDstrerror(errno)); report_once_flag = 1; HDgettimeofday(&timer_start, NULL); for (total_len = 0; total_len < file_size; total_len += src_len) write_file(src, src_len); HDclose(output); HDgettimeofday(&timer_stop, NULL); total_time = ((double)timer_stop.tv_sec + ((double)timer_stop.tv_usec) / MICROSECOND) - ((double)timer_start.tv_sec + ((double)timer_start.tv_usec) / MICROSECOND); HDfprintf(stdout, "\tCompressed Write Time: %.2fs\n", total_time); HDfprintf(stdout, "\tCompressed Write Throughput: %.2fMB/s\n", MB_PER_SEC(file_size, total_time)); HDfprintf(stdout, "\tCompression Time: %gs\n", compression_time); HDunlink(filename); HDfree(src); } }