foundationdb/fdbserver/workloads/UnitPerf.actor.cpp

70 lines
2.0 KiB
C++
Raw Normal View History

2017-05-26 04:48:44 +08:00
/*
* UnitPerf.actor.cpp
*
* This source file is part of the FoundationDB open source project
*
2022-03-22 04:36:23 +08:00
* Copyright 2013-2022 Apple Inc. and the FoundationDB project authors
*
2017-05-26 04:48:44 +08:00
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
2017-05-26 04:48:44 +08:00
* http://www.apache.org/licenses/LICENSE-2.0
*
2017-05-26 04:48:44 +08:00
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "fdbrpc/ActorFuzz.h"
#include "fdbserver/TesterInterface.actor.h"
#include "fdbserver/workloads/workloads.actor.h"
2019-02-18 10:46:59 +08:00
#include "flow/actorcompiler.h" // has to be last include
2017-05-26 04:48:44 +08:00
ACTOR Future<Void> sleepyActor(double interval, int* counter) {
loop {
wait(delay(interval));
2017-05-26 04:48:44 +08:00
++*counter;
}
}
ACTOR Future<Void> unitPerfTest() {
printf("\n");
state int counter = 0;
state std::vector<Future<Void>> sleepy;
sleepy.reserve(100000);
for (int i = 0; i < 100000; i++)
sleepy.push_back(sleepyActor(.1, &counter));
2017-05-26 04:48:44 +08:00
wait(delay(10));
2017-05-26 04:48:44 +08:00
sleepy.clear();
TraceEvent("Completed").detail("Count", counter);
printf("Completed: %d\n", counter);
printf("\n");
return Void();
}
struct UnitPerfWorkload : TestWorkload {
bool enabled;
UnitPerfWorkload(WorkloadContext const& wcx) : TestWorkload(wcx) {
2017-05-26 04:48:44 +08:00
enabled = !clientId; // only do this on the "first" client
}
2020-10-05 13:29:07 +08:00
std::string description() const override { return "UnitPerfWorkload"; }
Future<Void> setup(Database const& cx) override { return Void(); }
Future<Void> start(Database const& cx) override {
2017-05-26 04:48:44 +08:00
if (enabled)
return unitPerfTest();
return Void();
}
2020-10-05 13:29:07 +08:00
Future<bool> check(Database const& cx) override { return true; }
void getMetrics(std::vector<PerfMetric>& m) override {}
2017-05-26 04:48:44 +08:00
};
2019-02-18 10:46:59 +08:00
WorkloadFactory<UnitPerfWorkload> UnitPerfWorkloadFactory("UnitPerf");