mirror of
https://github.com/subhobhai943/SUB-OS.git
synced 2026-10-27 01:22:32 +00:00
feat(cpp,gui): C++ Analytics Engine + live GUI Analytics app
Kernel (C++17 freestanding):
- New Analytics Engine (kernel/cpp/cpp_analytics.cpp): templated rolling
time-series (TimeSeries<N>) sampling four live channels -- CPU load %,
memory %, kernel-heap %, network pkt/interval -- with windowed statistics
(min/max/mean/stddev) computed in pure integer math (kernel is -mno-sse, so
no FP; stddev uses a Newton integer isqrt). Demonstrates virtual dispatch
via an Observer pattern (IAnalyticsObserver + a ThresholdAlarmObserver that
counts breaches) and RAII singletons.
- Extended cpp_containers.hpp with Optional<T>, Pair<A,B>, and the kmin/kmax/
kclamp/kswap algorithms.
- Full C fallback (cpp_fallback.c) so the engine is functionally identical on
aarch64/armv8i, which don't build the .cpp path.
- Wired cpp_analytics_init() into boot [8/14]; seeds a few samples so graphs
are populated immediately.
GUI:
- New "Analytics" desktop app (gui/gui_apps.c): a 2x2 grid of live line-charts
backed by the C++ engine, each with gridlines, a soft baseline fill, and
min/avg/max(/stddev) overlays; click a panel to focus one channel full-size,
click again to return. Throttled to ~2 Hz sampling off the compositor's
repaint cadence. Registered on the desktop and in the start menu.
Userland: new `cppstat [samples]` applet dumps the engine's per-channel stats
and Observer breach counters.
Verified in QEMU (x86_64): boots clean on x86_64/aarch64/armv8i; `cppstat`
prints live stats (CPU 6%, Mem 7%, Heap 22%, computed min/avg/max/stddev,
Observer breaches); the GUI Analytics window renders all four graphs with the
Kernel Heap curve visibly climbing 22->55% as windows open, compositor steady
at ~53 FPS.
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Fh5z6V7nGPbHvqVG5p4CXX
This commit is contained in:
1 parent
cd840d5799
commit
5bd18c4733
9 files changed
+762
-2
No files matched your search
@@ -41,6 +41,7 @@
|
||||
#include <kernel/ktime.h>
|
||||
#include <kernel/sub_lang.h>
|
||||
#include <kernel/cpp_kernel.h>
|
||||
#include <kernel/cpp_analytics.h>
|
||||
#include <userland/snake.h>
|
||||
#include <ipc/shm_posix.h>
|
||||
#include <net/dns_cache.h>
|
||||
@@ -1328,6 +1329,15 @@ static int applet_cppbench(int argc, char** argv) {
|
||||
return cpp_run_benchmarks();
|
||||
}
|
||||
|
||||
static int applet_cppstat(int argc, char** argv) {
|
||||
int n = (argc >= 2) ? atoi(argv[1]) : 1;
|
||||
if (n < 1) n = 1;
|
||||
if (n > 32) n = 32;
|
||||
for (int i = 0; i < n; i++) cpp_analytics_sample();
|
||||
cpp_analytics_dump();
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int applet_shm(int argc, char** argv) {
|
||||
(void)argc; (void)argv;
|
||||
posix_shm_dump();
|
||||
@@ -2629,6 +2639,7 @@ static const lazybox_applet_t applets[] = {
|
||||
{"cpptest", applet_cpptest, "cpptest", "C++ polymorphism & new/del", "System"},
|
||||
{"cppdevs", applet_cppdevs, "cppdevs", "C++ OOP device tree", "System"},
|
||||
{"cppbench", applet_cppbench, "cppbench", "C++ OOP benchmark suite", "System"},
|
||||
{"cppstat", applet_cppstat, "cppstat [samples]", "C++ analytics engine stats", "System"},
|
||||
{"shm", applet_shm, "shm", "POSIX /dev/shm shared memory", "System"},
|
||||
{"dnscache", applet_dnscache, "dnscache [-f]", "DNS resolver cache & metrics", "Network"},
|
||||
{"beep", applet_beep, "beep [freq/jingle] [ms]", "PC speaker & HDA tone synth", "Sound"},
|
||||
|
||||
Reference in new issue
Block a user