Added a few utilities for perf testing.
This commit is contained in:
1 parent
7b0e3edfcf
commit
74f79a2f52
6 files changed
+64
-63
No files matched your search
@@ -3,54 +3,25 @@
|
||||
|
||||
#include "lib/mercury/actors/PingPong.h"
|
||||
#include "lib/mercury/executor/Executor.h"
|
||||
#include "lib/utils/thread_manager.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace bts {
|
||||
namespace cmd {
|
||||
|
||||
void test_ping_pong_mercury2()
|
||||
{
|
||||
using namespace mercury;
|
||||
|
||||
Executor ex1;
|
||||
Executor ex2;
|
||||
|
||||
ex1.init_neighbours(std::vector<Executor*> {&ex2});
|
||||
ex2.init_neighbours(std::vector<Executor*> {&ex1});
|
||||
|
||||
ex1.spawn<Ping>();
|
||||
//ex1.spawn<Pong>();
|
||||
ex2.spawn<Pong>();
|
||||
|
||||
auto t = std::thread([&ex2]() {
|
||||
cpu_set_t cpuset;
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(1, &cpuset);
|
||||
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
|
||||
while (true)
|
||||
ex2.do_work();
|
||||
});
|
||||
|
||||
bts::sleep_for(2s);
|
||||
|
||||
cpu_set_t cpuset;
|
||||
CPU_ZERO(&cpuset);
|
||||
CPU_SET(0, &cpuset);
|
||||
pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
|
||||
|
||||
while (true) {
|
||||
ex1.do_work();
|
||||
bts::sleep_for(100ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
int QuickTest::execute(std::vector<std::string> const &) {
|
||||
test_ping_pong_mercury2();
|
||||
return 0;
|
||||
threading::configure_current_thread("busy_poll");
|
||||
std::set<uint32_t> s;
|
||||
for (int i = 0; i < 1<<23;i++)
|
||||
s.insert(i);
|
||||
|
||||
auto sum = 0;
|
||||
for(;;) {
|
||||
for (auto &b : s)
|
||||
sum+=b;
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
std::string QuickTest::help() {
|
||||
|
||||
Reference in new issue
Block a user