From b33c0c564c51252ff241a2143e467dadfb8d8994 Mon Sep 17 00:00:00 2001 From: Clyne Sullivan Date: Wed, 8 Nov 2023 15:31:44 -0500 Subject: fib.fth benchmark; some minor coreword optimizations --- alee.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'alee.cpp') diff --git a/alee.cpp b/alee.cpp index 55cae57..99bc276 100644 --- a/alee.cpp +++ b/alee.cpp @@ -20,6 +20,7 @@ #include "memdict.hpp" #include +#include #include #include #include @@ -82,6 +83,8 @@ static void load(State& state) void user_sys(State& state) { + static std::chrono::time_point last; + static bool start = false; char buf[32] = {0}; switch (state.pop()) { @@ -102,6 +105,20 @@ void user_sys(State& state) case 4: // load load(state); break; + case 5: // time + if (!start) { + start = true; + last = std::chrono::high_resolution_clock::now(); + } else { + start = false; + auto diff = std::chrono::duration_cast( + std::chrono::high_resolution_clock::now() - last); + state.push((Cell)diff.count()); + } + break; + case 6: // double-add + { auto sum = state.popd() + state.popd(); state.pushd(sum); } + break; default: break; } -- cgit v1.2.3