Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
mrouffet committed Mar 30, 2024
2 parents 0fc3830 + 2ce4126 commit 8d96365
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 30 deletions.
2 changes: 1 addition & 1 deletion Include/SA/Logger/Misc/RindBuffer.inl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ namespace SA
void RingBuffer<T>::Push(T&& _obj)
{
// Reserve index.
uint32_t index = mPushCursor++;
uint64_t index = mPushCursor++;

/**
* Check is full
Expand Down
4 changes: 2 additions & 2 deletions Include/SA/Logger/Misc/RingBuffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ namespace SA

const uint32_t mCapacity = 0;

std::atomic<uint32_t> mPushCursor = 0;
std::atomic<uint32_t> mPopCursor = 0;
std::atomic<uint64_t> mPushCursor = 0u;
std::atomic<uint64_t> mPopCursor = 0u;

public:
/**
Expand Down
59 changes: 32 additions & 27 deletions Tests/PrototypeMT/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,53 @@ void LoggingThread()

int main()
{
std::chrono::time_point<std::chrono::system_clock> start, end;
std::chrono::time_point<std::chrono::system_clock> start, submitEnd, end;

//{
//{ Init
//{ Init

SA::LoggerThread loggerThread(3000);
SA::LoggerThread loggerThread(4000);

loggerThread.CreateSteam<SA::ConsoleLogStream>();
loggerThread.CreateSteam<SA::FileLogStream>();
loggerThread.CreateSteam<SA::ConsoleLogStream>();
loggerThread.CreateSteam<SA::FileLogStream>();

SA::Debug::logger = &loggerThread;
SA::Debug::logger = &loggerThread;

//}
//}

start = std::chrono::system_clock::now();
start = std::chrono::system_clock::now();

std::thread t1(LoggingThread);
std::thread t2(LoggingThread);
std::thread t3(LoggingThread);
std::thread t4(LoggingThread);
std::thread t1(LoggingThread);
std::thread t2(LoggingThread);
std::thread t3(LoggingThread);
std::thread t4(LoggingThread);

if (t1.joinable())
t1.join();
if (t1.joinable())
t1.join();

if (t2.joinable())
t2.join();
if (t2.joinable())
t2.join();

if (t3.joinable())
t3.join();
if (t3.joinable())
t3.join();

if (t4.joinable())
t4.join();
if (t4.joinable())
t4.join();

loggerThread.Flush();
//}
submitEnd = std::chrono::system_clock::now();

loggerThread.Flush();

end = std::chrono::system_clock::now();

auto time = end - start;
std::cout << "elapsed time: " <<
std::chrono::duration_cast<std::chrono::milliseconds>(time).count() << "ms / " <<
std::chrono::duration_cast<std::chrono::microseconds>(time).count() << "μs" << std::endl;
auto submitTime = submitEnd - start;
std::cout << "Total submitted time: " <<
std::chrono::duration_cast<std::chrono::milliseconds>(submitTime).count() << "ms / " <<
std::chrono::duration_cast<std::chrono::microseconds>(submitTime).count() << "μs" << std::endl;

auto totalTime = end - start;
std::cout << "Total elapsed time: " <<
std::chrono::duration_cast<std::chrono::milliseconds>(totalTime).count() << "ms / " <<
std::chrono::duration_cast<std::chrono::microseconds>(totalTime).count() << "μs" << std::endl;

return 0;
}

0 comments on commit 8d96365

Please sign in to comment.