aboutsummaryrefslogtreecommitdiffstats
path: root/vbench/src/tests/qps_analyzer/qps_analyzer_test.cpp
blob: 54cf94a57b11ba5d207a2d782aa4294b7da9b507 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <vespa/vespalib/testkit/testapp.h>
#include <vbench/test/all.h>

using namespace vbench;

void post(double endTime, Handler<Request> &handler,
          Request::Status status = Request::STATUS_OK)
{
    Request::UP req(new Request());
    req->status(status).endTime(endTime);
    handler.handle(std::move(req));
}

TEST_FF("simulate 100 qps", RequestSink(), QpsAnalyzer(f1)) {
    for (size_t i = 1; i < 10000; ++i) {
        post(i * 0.01, f2);
        post(i * 0.01, f2, Request::STATUS_DROPPED);
        post(i * 0.01, f2, Request::STATUS_FAILED);
    }
}

TEST_MAIN() { TEST_RUN_ALL(); }