From d5750874874c8adc8830f36d6e4b3b7b4e175520 Mon Sep 17 00:00:00 2001 From: Reece Date: Sat, 2 Apr 2022 01:50:21 +0100 Subject: [PATCH] [+] Exit [*] Update [*] Formatting --- Aurora/ROXTL | 2 +- Aurora/Runtime | 2 +- Tests/Public/18. Hello Exit/Main.cpp | 65 ++++++++++++++++++++++++++++ Tests/Public/20. Hello Time/Main.cpp | 38 ++++++++++++++++ Tests/Public/5. Hello Loop/Main.cpp | 5 +-- 5 files changed, 107 insertions(+), 5 deletions(-) create mode 100644 Tests/Public/18. Hello Exit/Main.cpp create mode 100644 Tests/Public/20. Hello Time/Main.cpp diff --git a/Aurora/ROXTL b/Aurora/ROXTL index a19ae80..3d14595 160000 --- a/Aurora/ROXTL +++ b/Aurora/ROXTL @@ -1 +1 @@ -Subproject commit a19ae800aa9ba41c185aa4720442fca41732c50d +Subproject commit 3d14595d87eab4b056c39e54228df9cb694a0912 diff --git a/Aurora/Runtime b/Aurora/Runtime index 7e1bf30..5599da3 160000 --- a/Aurora/Runtime +++ b/Aurora/Runtime @@ -1 +1 @@ -Subproject commit 7e1bf30131146ac22e08568657b0be0669f343de +Subproject commit 5599da3ab06885d365bab1234459c76f623a7c45 diff --git a/Tests/Public/18. Hello Exit/Main.cpp b/Tests/Public/18. Hello Exit/Main.cpp new file mode 100644 index 0000000..68fdc74 --- /dev/null +++ b/Tests/Public/18. Hello Exit/Main.cpp @@ -0,0 +1,65 @@ +/*** + Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. + + File: Main.cpp + Date: 2022-2-18 + Author: Reece +***/ +#include +#include + +static void AddHooks() +{ + AuExit::ExitHandlerAdd(AuExit::ETriggerLevel::eProblematicEvent, + AuMakeShared( + [](AuExit::ETriggerLevel level, const AuExit::ExitInvoker *pInvoker) + { + AuLogInfo("A problematic event occoured"); + })); + + AuExit::ExitHandlerAdd(AuExit::ETriggerLevel::eFatalException, + AuMakeShared( + [](AuExit::ETriggerLevel level, const AuExit::ExitInvoker *pInvoker) + { + AuLogInfo("A fatal event occoured"); + })); + + AuExit::ExitHandlerAdd(AuExit::ETriggerLevel::eSigTerminate, + AuMakeShared( + [](AuExit::ETriggerLevel level, const AuExit::ExitInvoker *pInvoker) + { + AuLogInfo("A terminate event was sent"); + // You must synchronize / join all spawned threads here + // Aurora APIs may become unstable after this point + // Yes, we can try to design around and mitigate issues, but it's time to go... + })); + + AuExit::ExitHandlerAdd(AuExit::ETriggerLevel::eSafeTermination, + AuMakeShared( + [](AuExit::ETriggerLevel level, const AuExit::ExitInvoker *pInvoker) + { + AuLogInfo("Safe termination of application"); + })); + + AuLogInfo("Throwing exception..."); + try + { + AU_THROW_STRING("hi"); + } + catch (...) + { + + } + + AuLogInfo("Sleeping for 20s. Send a control+c, if you want"); + AuThreading::Sleep(20'000); +} + +void RunTests() +{ + Aurora::RuntimeStartInfo info; + info.console.fio.enableLogging = false; + Aurora::RuntimeStart(info); + + AddHooks(); +} \ No newline at end of file diff --git a/Tests/Public/20. Hello Time/Main.cpp b/Tests/Public/20. Hello Time/Main.cpp new file mode 100644 index 0000000..853d2ff --- /dev/null +++ b/Tests/Public/20. Hello Time/Main.cpp @@ -0,0 +1,38 @@ +/*** + Copyright (C) 2022 J Reece Wilson (a/k/a "Reece"). All rights reserved. + + File: Main.cpp + Date: 2022-2-18 + Author: Reece +***/ +#include +#include + +TEST(Benchmark, CurrentInternalClockMS) +{ + SysBenchmark("CurrentInternalClockMS"); + + AuUInt c {}; + for (int i = 0; i < 100'000'000; i++) + { + c += AuTime::CurrentInternalClockMS(); + } +} + +TEST(Benchmark, CurrentClockMS) +{ + SysBenchmark("CurrentClockMS"); + + AuUInt c {}; + for (int i = 0; i < 100'000'000; i++) + { + c += AuTime::CurrentClockMS(); + } +} + +void RunTests() +{ + Aurora::RuntimeStartInfo info; + info.console.fio.enableLogging = false; + Aurora::RuntimeStart(info); +} \ No newline at end of file diff --git a/Tests/Public/5. Hello Loop/Main.cpp b/Tests/Public/5. Hello Loop/Main.cpp index bb75a26..de0172a 100644 --- a/Tests/Public/5. Hello Loop/Main.cpp +++ b/Tests/Public/5. Hello Loop/Main.cpp @@ -130,7 +130,7 @@ TEST(Loop, Performance) ...not bad, here's why: Reece, [30/03/2022 19:39] - 1 whole frame (~20Hhz) of work to blast WaitForMultipleObjectsEx/io_submit/epoll abstraction with a test covering multiple apis 10k times/iterations + 1 whole frame (~20Hz) of work to blast WaitForMultipleObjectsEx/io_submit/epoll abstraction with a test covering multiple apis 10k times/iterations Reece, [30/03/2022 19:39] imagine a scheduling thread working on 10k unique kernel work objects per frame @@ -148,7 +148,7 @@ TEST(Loop, Performance) by "like" i mean 10k iterations * 4 apis that can dispatch a callback or yield to kernel Reece, [30/03/2022 19:42] - best practices say you dont fucking spam resources. 40k is a hell of a lot more than, idk, checking a file read transaction a few tens-to-hundreds of times a second on an serializer thread that's not-io bound + best practices say you dont fucking spam resources. 40k is a hell of a lot more than, idk, checking a file read transaction a few tens-to-hundreds of times a second on an serializer thread that's not io-bound Further data: @@ -217,7 +217,6 @@ TEST(Loop, Performance) semaA->AddOne(); // account for initial starting count of 1 } - printf("."); } void RunTests()