feat delete unused file
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 14s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Failing after 16s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 14s
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Failing after 18s
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Failing after 20s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 23s
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Failing after 29s
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Failing after 16s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 24s
linux-x64-gcc / linux-gcc (Release) (push) Failing after 25s
android / build (push) Failing after 14m18s
linux-arm-gcc / linux-gcc-arm (Release) (push) Failing after 13m59s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Failing after 13m55s
linux-arm-gcc / linux-gcc-armhf (Release) (push) Failing after 13m53s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 11m19s
linux-x86-gcc / linux-gcc (Release) (push) Failing after 22s
linux-x86-gcc / linux-gcc (Debug) (push) Failing after 1m9s
Some checks failed
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Debug) (push) Failing after 14s
linux-aarch64-cpu-gcc / linux-gcc-aarch64 (Release) (push) Failing after 16s
linux-arm-gcc / linux-gcc-arm (Debug) (push) Failing after 14s
linux-mips-gcc / linux-gcc-mipsel (Release) (push) Failing after 18s
linux-riscv64-gcc / linux-gcc-riscv64 (Debug) (push) Failing after 20s
linux-mips64-gcc / linux-gcc-mips64el (Release) (push) Failing after 23s
linux-mips-gcc / linux-gcc-mipsel (Debug) (push) Failing after 29s
linux-riscv64-gcc / linux-gcc-riscv64 (Release) (push) Failing after 16s
linux-x64-gcc / linux-gcc (Debug) (push) Failing after 24s
linux-x64-gcc / linux-gcc (Release) (push) Failing after 25s
android / build (push) Failing after 14m18s
linux-arm-gcc / linux-gcc-arm (Release) (push) Failing after 13m59s
linux-arm-gcc / linux-gcc-armhf (Debug) (push) Failing after 13m55s
linux-arm-gcc / linux-gcc-armhf (Release) (push) Failing after 13m53s
linux-mips64-gcc / linux-gcc-mips64el (Debug) (push) Failing after 11m19s
linux-x86-gcc / linux-gcc (Release) (push) Failing after 22s
linux-x86-gcc / linux-gcc (Debug) (push) Failing after 1m9s
This commit is contained in:
parent
8189ae12e3
commit
319647bd11
@ -1,37 +0,0 @@
|
|||||||
#include "tile/fiber/detail/fiber.h"
|
|
||||||
|
|
||||||
#include "tile/base/random.h"
|
|
||||||
#include "tile/base/string.h"
|
|
||||||
|
|
||||||
#include "benchmark/benchmark.h"
|
|
||||||
|
|
||||||
namespace tile {
|
|
||||||
namespace fiber {
|
|
||||||
namespace detail {
|
|
||||||
void Benchmark_FiberSwitch(benchmark::State &state) {
|
|
||||||
std::unique_ptr<Fiber> master_fiber;
|
|
||||||
|
|
||||||
int switch_cnt = 0;
|
|
||||||
master_fiber = Fiber::Create([&] {
|
|
||||||
while (state.KeepRunning()) {
|
|
||||||
std::unique_ptr<Fiber> worker_fiber1 =
|
|
||||||
Fiber::Create([&] { ++switch_cnt; });
|
|
||||||
|
|
||||||
auto start = std::chrono::steady_clock::now();
|
|
||||||
worker_fiber1->Resume();
|
|
||||||
auto end = std::chrono::steady_clock::now();
|
|
||||||
auto elapsed = std::chrono::duration_cast<std::chrono::duration<double>>(
|
|
||||||
end - start);
|
|
||||||
state.SetIterationTime(elapsed.count());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
master_fiber->Resume();
|
|
||||||
state.counters["switch_cnt"] = switch_cnt;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace fiber
|
|
||||||
} // namespace tile
|
|
||||||
|
|
||||||
BENCHMARK(tile::fiber::detail::Benchmark_FiberSwitch)->UseManualTime();
|
|
@ -1,52 +0,0 @@
|
|||||||
#include "tile/base/random.h"
|
|
||||||
#include "tile/fiber/detail/fiber.h"
|
|
||||||
|
|
||||||
#include "gtest/gtest.h"
|
|
||||||
namespace tile {
|
|
||||||
namespace fiber {
|
|
||||||
namespace detail {
|
|
||||||
|
|
||||||
TEST(Fiber, Base) {
|
|
||||||
constexpr auto kMaxCnt = 1; // 100 * 1000;
|
|
||||||
int cnt = 0;
|
|
||||||
int resume_cnt = 0;
|
|
||||||
|
|
||||||
// 0 -> master fiber
|
|
||||||
// [1, 9] -> worker fibers
|
|
||||||
std::unique_ptr<Fiber> master_fiber;
|
|
||||||
|
|
||||||
master_fiber = Fiber::Create([&] {
|
|
||||||
TILE_LOG_INFO("master fiber");
|
|
||||||
// ASSERT_EQ(cnt, 0);
|
|
||||||
ASSERT_EQ(GetMasterFiber(), master_fiber.get());
|
|
||||||
ASSERT_EQ(GetCurrentFiber(), master_fiber.get());
|
|
||||||
|
|
||||||
ASSERT_EQ(cnt, 0);
|
|
||||||
while (cnt < kMaxCnt) {
|
|
||||||
std::unique_ptr<Fiber> worker_fiber = Fiber::Create([&] {
|
|
||||||
while (cnt < kMaxCnt) {
|
|
||||||
ASSERT_EQ(GetCurrentFiber(), worker_fiber.get());
|
|
||||||
++cnt;
|
|
||||||
master_fiber->Resume();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
while (cnt < kMaxCnt) {
|
|
||||||
int old = cnt;
|
|
||||||
worker_fiber->Resume();
|
|
||||||
ASSERT_EQ(old + 1, cnt);
|
|
||||||
ASSERT_EQ(GetCurrentFiber(), master_fiber.get());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT_EQ(cnt, kMaxCnt);
|
|
||||||
});
|
|
||||||
|
|
||||||
SetUpMasterFiber(master_fiber.get());
|
|
||||||
SetUpCurrentFiber(nullptr);
|
|
||||||
master_fiber->Resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace detail
|
|
||||||
} // namespace fiber
|
|
||||||
} // namespace tile
|
|
@ -1,35 +0,0 @@
|
|||||||
#ifndef TILE_FIBER_THIS_FIBER_H
|
|
||||||
#define TILE_FIBER_THIS_FIBER_H
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "tile/base/chrono.h"
|
|
||||||
#include "tile/fiber/fiber.h"
|
|
||||||
#include <chrono>
|
|
||||||
|
|
||||||
namespace tile {
|
|
||||||
namespace this_fiber {
|
|
||||||
|
|
||||||
Fiber::Id GetId();
|
|
||||||
|
|
||||||
void Yield();
|
|
||||||
|
|
||||||
void SleepUntil(std::chrono::steady_clock expires_at);
|
|
||||||
|
|
||||||
void SleepFor(std::chrono::nanoseconds expires_in);
|
|
||||||
|
|
||||||
template <typename Clock, typename Duration>
|
|
||||||
void SleepUntil(const std::chrono::time_point<Clock, Duration> &expires_at) {
|
|
||||||
return SleepUntil(ReadSteadyClock() + (expires_at - Clock::now()));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename Rep, typename Period>
|
|
||||||
void SleepFor(const std::chrono::duration<Rep, Period> &expires_in) {
|
|
||||||
return SleepFor(
|
|
||||||
std::chrono::duration_cast<std::chrono::nanoseconds>(expires_in));
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace this_fiber
|
|
||||||
} // namespace tile
|
|
||||||
|
|
||||||
#endif // TILE_FIBER_THIS_FIBER_H
|
|
Loading…
x
Reference in New Issue
Block a user