Ejemplo n.º 1
0
	FormattedStream& operator<<(FormattedStream& os, const BenchmarkCompareResults& bm) {
		os << "=== BENCHMARK/COMPARE: " << bm.description << '\n';
		if (bm.results.size()) {
			os << "BEST: " << bm.results.front().description << '\n';
			print_benchmark_results(os, bm.results.front(), false);
		}
		if (bm.results.size() > 1) {
			os << "WORST: " << bm.results.back().description << '\n';
			print_benchmark_results(os, bm.results.back(), false);
		}
		return os;
	}
Ejemplo n.º 2
0
	FormattedStream& operator<<(FormattedStream& os, const BenchmarkResults& bm) {
		print_benchmark_results(os, bm, true);
		return os;
	}
Ejemplo n.º 3
0
bool CLIENT_STATE::cpu_benchmarks_poll() {
    int i;
    static double last_time = 0;
    if (!benchmarks_running) return false;

    if (!clock_change && now < last_time + BENCHMARK_POLL_PERIOD) return false;
    last_time = now;

    active_tasks.send_heartbeats();

    // if active tasks don't quit after 10 sec, give up on benchmark
    //
    if (gstate.clock_change || (now >= (cpu_benchmarks_start + 10.0) && active_tasks.is_task_executing())) {
        msg_printf(NULL, MSG_INTERNAL_ERROR,
            "Failed to stop applications; aborting CPU benchmarks"
        );
        host_info.p_calculated = now;
        abort_cpu_benchmarks();
        benchmarks_running = false;
        set_client_state_dirty("CPU benchmarks");
        cpu_benchmarks_pending = true;
        return false;
    }

    // do transitions through benchmark states
    //
    switch (bm_state) {
    case BM_FP_INIT:
        if (now - cpu_benchmarks_start > FP_START) {
            if (log_flags.benchmark_debug) {
                msg_printf(0, MSG_INFO,
                    "[benchmark] Starting floating-point benchmark"
                );
            }
            make_benchmark_file(BM_TYPE_FP);
            bm_state = BM_FP;
        }
        return false;
    case BM_FP:
        if (now - cpu_benchmarks_start > FP_END) {
            if (log_flags.benchmark_debug) {
                msg_printf(0, MSG_INFO,
                    "[benchmark] Ended floating-point benchmark"
                );
            }
            remove_benchmark_file(BM_TYPE_FP);
            bm_state = BM_INT_INIT;
        }
        return false;
    case BM_INT_INIT:
        if (now - cpu_benchmarks_start > INT_START) {
            if (log_flags.benchmark_debug) {
                msg_printf(0, MSG_INFO,
                    "[benchmark] Starting integer benchmark"
                );
            }
            make_benchmark_file(BM_TYPE_INT);
            bm_state = BM_INT;
        }
        return false;
    case BM_INT:
        if (now - cpu_benchmarks_start > INT_END) {
            if (log_flags.benchmark_debug) {
                msg_printf(0, MSG_INFO,
                    "[benchmark] Ended integer benchmark"
                );
            }
            remove_benchmark_file(BM_TYPE_INT);
            bm_state = BM_SLEEP;
        }
        return false;
    case BM_SLEEP:
        if (now - cpu_benchmarks_start > OVERALL_END) {
            if (log_flags.benchmark_debug) {
                msg_printf(0, MSG_INFO,
                    "[benchmark] Ended benchmark"
                );
            }
            bm_state = BM_DONE;
        }
        return false;
    }

    // check for timeout
    //
    if (now > cpu_benchmarks_start + MAX_CPU_BENCHMARKS_SECONDS) {
        msg_printf(NULL, MSG_INTERNAL_ERROR,
            "CPU benchmarks timed out, using default values"
        );
        abort_cpu_benchmarks();
        cpu_benchmarks_set_defaults();
        benchmarks_running = false;
        set_client_state_dirty("CPU benchmarks");
    }

    int ndone = 0;
    bool had_error = false;
    for (i=0; i<bm_ncpus; i++) {
        if (!benchmark_descs[i].done) {
            check_benchmark(benchmark_descs[i]);
        }
        if (benchmark_descs[i].done) {
            if (log_flags.benchmark_debug) {
                msg_printf(0, MSG_INFO,
                    "[benchmark] CPU %d has finished", i
                );
            }
            ndone++;
            if (benchmark_descs[i].error) {
                msg_printf(0, MSG_INFO, "%s", benchmark_descs[i].error_str);
                had_error = true;
            }
        }
    }
    if (log_flags.benchmark_debug) {
        msg_printf(0, MSG_INFO,
            "[benchmark] %d out of %d CPUs done", ndone, bm_ncpus
        );
    }
    if (ndone == bm_ncpus) {
        double old_p_fpops = host_info.p_fpops;
        if (had_error) {
            cpu_benchmarks_set_defaults();
        } else {
            double p_fpops = 0;
            double p_iops = 0;
            double p_membw = 0;
            for (i=0; i<bm_ncpus; i++) {
                if (log_flags.benchmark_debug) {
                    msg_printf(0, MSG_INFO,
                        "[benchmark] CPU %d: fp %f int %f intloops %f inttime %f",
                        i, benchmark_descs[i].host_info.p_fpops,
                        benchmark_descs[i].host_info.p_iops,
                        benchmark_descs[i].int_loops,
                        benchmark_descs[i].int_time
                    );
                }
                p_fpops += benchmark_descs[i].host_info.p_fpops;
#ifdef _WIN32
                p_iops += benchmark_descs[0].host_info.p_iops;
#else
                p_iops += benchmark_descs[i].host_info.p_iops;
#endif
                p_membw += benchmark_descs[i].host_info.p_membw;
            }
            p_fpops /= bm_ncpus;
            p_iops /= bm_ncpus;
            p_membw /= bm_ncpus;
            if (p_fpops > 0) {
                host_info.p_fpops = p_fpops;
            } else {
                msg_printf(NULL, MSG_INTERNAL_ERROR, "Benchmark: FP unexpectedly zero; ignoring");
            }
            if (p_iops > 0) {
                host_info.p_iops = p_iops;
            } else {
                msg_printf(NULL, MSG_INTERNAL_ERROR, "Benchmark: int unexpectedly zero; ignoring");
            }
            host_info.p_membw = p_membw;
            print_benchmark_results();
            did_benchmarks = true;
        }

        // scale duration correction factor according to change in benchmarks.
        //
        if (host_info.p_calculated && old_p_fpops) {
            scale_duration_correction_factors(host_info.p_fpops/old_p_fpops);
        }
        host_info.p_calculated = now;
        benchmarks_running = false;
        set_client_state_dirty("CPU benchmarks");
    }
    return false;
}