19
19
20
20
#include " Debug.h"
21
21
#include " LuaTools.h"
22
+ #include " MemAccess.h"
22
23
#include " PluginManager.h"
23
24
#include " VTableInterpose.h"
24
25
@@ -40,6 +41,11 @@ namespace DFHack {
40
41
41
42
static df::coord2d screenSize;
42
43
44
+ // instrumentation
45
+ uint32_t total_overlay_ms = 0 ;
46
+ static uint32_t get_framework_timer () { return total_overlay_ms; }
47
+ static void reset_framework_timer () { total_overlay_ms = 0 ; }
48
+
43
49
static void call_overlay_lua (color_ostream *out, const char *fn_name,
44
50
int nargs = 0 , int nres = 0 ,
45
51
Lua::LuaLambda && args_lambda = Lua::DEFAULT_LUA_LAMBDA,
@@ -48,6 +54,8 @@ static void call_overlay_lua(color_ostream *out, const char *fn_name,
48
54
49
55
CoreSuspender guard;
50
56
57
+ uint32_t start_ms = Core::getInstance ().p ->getTickCount ();
58
+
51
59
auto L = Lua::Core::State;
52
60
Lua::StackUnwinder top (L);
53
61
@@ -57,6 +65,8 @@ static void call_overlay_lua(color_ostream *out, const char *fn_name,
57
65
Lua::CallLuaModuleFunction (*out, L, " plugins.overlay" , fn_name, nargs, nres,
58
66
std::forward<Lua::LuaLambda&&>(args_lambda),
59
67
std::forward<Lua::LuaLambda&&>(res_lambda));
68
+
69
+ total_overlay_ms += Core::getInstance ().p ->getTickCount () - start_ms;
60
70
}
61
71
62
72
template <class T >
@@ -198,3 +208,9 @@ DFhackCExport command_result plugin_onupdate (color_ostream &out) {
198
208
call_overlay_lua (&out, " update_hotspot_widgets" );
199
209
return CR_OK;
200
210
}
211
+
212
+ DFHACK_PLUGIN_LUA_FUNCTIONS {
213
+ DFHACK_LUA_FUNCTION (get_framework_timer),
214
+ DFHACK_LUA_FUNCTION (reset_framework_timer),
215
+ DFHACK_LUA_END
216
+ };
0 commit comments