blob: 1a60116cafc7c02e05cad26f539f36d1e02ae1cd (
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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "debug_wait.h"
#include <vespa/vespalib/util/time.h>
#include <vespa/vespalib/util/stash.h>
using namespace search::fef;
namespace search::features {
//-----------------------------------------------------------------------------
class DebugWaitExecutor : public FeatureExecutor
{
private:
DebugWaitParams _params;
public:
DebugWaitExecutor(const IQueryEnvironment &env, const DebugWaitParams ¶ms);
void execute(uint32_t docId) override;
};
DebugWaitExecutor::DebugWaitExecutor(const IQueryEnvironment &, const DebugWaitParams ¶ms)
: _params(params)
{
}
using namespace std::chrono;
void
DebugWaitExecutor::execute(uint32_t)
{
vespalib::Timer timer;
vespalib::Timer::waitAtLeast(vespalib::from_s(_params.waitTime), _params.busyWait);
outputs().set_number(0, vespalib::to_s(timer.elapsed()));
}
//-----------------------------------------------------------------------------
DebugWaitBlueprint::DebugWaitBlueprint()
: Blueprint("debugWait"),
_params()
{
}
void
DebugWaitBlueprint::visitDumpFeatures(const IIndexEnvironment &, IDumpFeatureVisitor &) const
{
}
Blueprint::UP
DebugWaitBlueprint::createInstance() const
{
return std::make_unique<DebugWaitBlueprint>();
}
bool
DebugWaitBlueprint::setup(const IIndexEnvironment &env, const ParameterList ¶ms)
{
(void)env;
_params.waitTime = params[0].asDouble();
_params.busyWait = (params[1].asDouble() == 1.0);
describeOutput("out", "actual time waited");
return true;
}
FeatureExecutor &
DebugWaitBlueprint::createExecutor(const IQueryEnvironment &env, vespalib::Stash &stash) const
{
return stash.create<DebugWaitExecutor>(env, _params);
}
//-----------------------------------------------------------------------------
}
|