diff options
author | Clyne Sullivan <clyne@bitgloo.com> | 2023-11-08 15:31:44 -0500 |
---|---|---|
committer | Clyne Sullivan <clyne@bitgloo.com> | 2023-11-08 15:31:44 -0500 |
commit | b33c0c564c51252ff241a2143e467dadfb8d8994 (patch) | |
tree | 1e090f690843d9daf9c3fda7e08187bc7ea9fadb /alee.cpp | |
parent | 8e7cb05cfb2903e3c6a3e0bf713282cf50563590 (diff) |
fib.fth benchmark; some minor coreword optimizations
Diffstat (limited to 'alee.cpp')
-rw-r--r-- | alee.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
@@ -20,6 +20,7 @@ #include "memdict.hpp" #include <charconv> +#include <chrono> #include <fstream> #include <iostream> #include <vector> @@ -82,6 +83,8 @@ static void load(State& state) void user_sys(State& state) { + static std::chrono::time_point<std::chrono::high_resolution_clock> 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::microseconds>( + 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; } |