userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
stress.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <chrono>
7
8
#include <
userver/engine/deadline.hpp
>
9
10
#include <userver/compiler/impl/asan.hpp>
11
#include <userver/compiler/impl/tsan.hpp>
12
13
USERVER_NAMESPACE_BEGIN
14
15
namespace
utest
{
16
26
class
StressLoop
{
27
public
:
28
struct
Iterator
{
29
StressLoop
& loop;
30
31
struct
Value
{
32
~Value
() {
33
(void)0;
// force non-trivial destructor
34
}
35
};
36
37
void
operator++() {}
38
Value operator*() {
return
{}; }
39
bool
operator==(
const
Iterator&)
const
{
return
loop.ShouldStop(); }
40
bool
operator!=(
const
Iterator&)
const
{
return
!loop.ShouldStop(); }
41
};
42
43
Iterator
begin() {
return
{*
this
}; }
44
45
Iterator
end() {
return
{*
this
}; }
46
47
bool
ShouldStop()
const
{
return
deadline_.IsReached(); }
48
49
private
:
50
#if USERVER_IMPL_HAS_TSAN || USERVER_IMPL_HAS_ASAN
51
// Too many iterations with sanitizers may consume too much virtual memory and crach the application
52
static
constexpr
std::chrono::milliseconds kMaxStressTestWaitTime{300};
53
#else
54
static
constexpr
std::chrono::seconds kMaxStressTestWaitTime{30};
55
#endif
56
57
engine::Deadline deadline_{
engine::Deadline::FromDuration
(kMaxStressTestWaitTime)};
58
};
59
60
}
// namespace utest
61
62
USERVER_NAMESPACE_END
userver
utest
stress.hpp
Generated on
for userver by
Doxygen
1.17.0