Exemplo n.º 1
0
TEST_F(BenchmarkTest, it_measures_time_consuming) {
	Benchmark benchmark;
	benchmark.start();
	int time_to_sleep = 1;
	suspend(time_to_sleep);
	ASSERT_TRUE(time_to_sleep <= benchmark.end());
}
Exemplo n.º 2
0
void BenchWidget::paintEvent(QPaintEvent *)
{
    if (m_done)
        return;

    QPainter p(this);

    m_benchmark->begin(&p, 100);

    PaintingRectAdjuster adjuster;
    adjuster.setNewBenchmark(m_benchmark);
    adjuster.reset(rect());

    for (int i = 0; i < 100; ++i)
        m_benchmark->draw(&p, adjuster.newPaintingRect(), i);

    m_benchmark->end(&p);

    ++m_iteration;

    uint currentElapsed = timer.isNull() ? 0 : timer.elapsed();
    timer.restart();

    m_total += currentElapsed;

    // warm up for at most 5 iterations or half a second
    if (m_iteration >= 5 || m_total >= 500) {
        iterationTimes << currentElapsed;

        if (iterationTimes.size() >= 5) {
            qreal mean = 0;
            qreal stddev = 0;
            uint min = INT_MAX;

            for (int i = 0; i < iterationTimes.size(); ++i) {
                mean += iterationTimes.at(i);
                min = qMin(min, iterationTimes.at(i));
            }

            mean /= qreal(iterationTimes.size());

            for (int i = 0; i < iterationTimes.size(); ++i) {
                qreal delta = iterationTimes.at(i) - mean;
                stddev += delta * delta;
            }

            stddev = qSqrt(stddev / iterationTimes.size());

            stddev = 100 * stddev / mean;
            // do 50 iterations, break earlier if we spend more than 5 seconds or have a low std deviation after 2 seconds
            if (iterationTimes.size() >= 50 || m_total >= 5000 || (m_total >= 2000 && stddev < 4)) {
                m_result = min;
                m_done = true;
                return;
            }
        }
    }
}
Exemplo n.º 3
0
TEST_F(PerformanceTest, DISABLED_test_performance) {
	DiskHammalFactory factory(GBYTES11FILE);
	OutputWriter writer(GBYTESRESULT);
	JobConfiguration configuration(1, 150 * 1024 * 1024, 10, 20);
	JobClient client(configuration, factory, writer);
	SimpleWordMapper mapper;
    Benchmark benchmark;
    benchmark.start();
	client.run_job(mapper);
    std::cout << "Elapsed time in second:" << benchmark.end() << std::endl;
}
Exemplo n.º 4
0
TEST_F(BenchmarkTest, it_returns_error_if_end_is_called_after_end) {
	Benchmark benchmark;
	benchmark.start();
	benchmark.end();
	ASSERT_EQ(-1, benchmark.end());
}
Exemplo n.º 5
0
TEST_F(BenchmarkTest, it_returns_error_if_end_is_called_before_start) {
	Benchmark benchmark;
	ASSERT_EQ(-1, benchmark.end());
}