add tracking of garbage collections
This commit is contained in:
parent
0666f4d949
commit
ad1bcd45c7
|
@ -339,16 +339,28 @@ function printreport(cache, name) {
|
|||
};
|
||||
|
||||
profile.data = {};
|
||||
profile.data.cpu = {};
|
||||
profile.data.cpu = {
|
||||
scripts: [],
|
||||
render: [],
|
||||
physics: [],
|
||||
};
|
||||
|
||||
profile.data.gpu = {};
|
||||
profile.data.physics = {};
|
||||
profile.data.script = {};
|
||||
profile.data.memory = {};
|
||||
var frame = 0;
|
||||
|
||||
profile.pushdata = function(arr, val)
|
||||
{
|
||||
if (arr.last() !== val)
|
||||
arr[frame] = val;
|
||||
}
|
||||
|
||||
profile.capture_data = function()
|
||||
{
|
||||
var mem = os.mem();
|
||||
var memo = profile.data.script;
|
||||
var memo = profile.data.memory;
|
||||
for (var i in mem) {
|
||||
memo[i] ??= [];
|
||||
if (memo[i].last() !== mem[i])
|
||||
|
@ -365,19 +377,6 @@ profile.best_mem = function(bytes)
|
|||
return (bytes / Math.pow(1024, i)).toPrecision(3) + ' ' + sizes[i];
|
||||
}
|
||||
|
||||
profile.print_mem = function()
|
||||
{
|
||||
var mem = os.mem();
|
||||
say('total memory used: ' + profile.best_mem(mem.memory_used_size));
|
||||
say('total malloced: ' + profile.best_mem(mem.malloc_size));
|
||||
delete mem.memory_used_size;
|
||||
delete mem.malloc_size;
|
||||
for (var i in mem) {
|
||||
if (i. includes("size"))
|
||||
say(" " + i + " :: " + profile.best_mem(mem[i]));
|
||||
}
|
||||
}
|
||||
|
||||
profile.last_mem = undefined;
|
||||
profile.mems = [];
|
||||
profile.gcs = [];
|
||||
|
@ -385,13 +384,8 @@ profile.print_gc = function()
|
|||
{
|
||||
var gc = os.check_gc();
|
||||
if (!gc) return;
|
||||
profile.gcs.push(gc);
|
||||
profile.mems.push(os.mem());
|
||||
say("GC Hit");
|
||||
say (`time: ${profile.best_t(gc.time)}`);
|
||||
say(`new threshold: ${profile.best_mem(profile.mems.last().gc_threshold)}`);
|
||||
say(`memory checked: ${profile.best_mem(profile.gcs.last().mem)}`);
|
||||
say(`memory freed: ${profile.best_mem(profile.gcs.last().startmem - profile.gcs.last().mem)}`);
|
||||
profile.data.gc ??= [];
|
||||
profile.data.gc[frame] = gc;
|
||||
}
|
||||
|
||||
return {profile};
|
||||
|
|
|
@ -1189,12 +1189,16 @@ prosperon.process = function process() {
|
|||
var dt = profile.secs(profile.now()) - frame_t;
|
||||
frame_t = profile.secs(profile.now());
|
||||
|
||||
var sst = profile.now();
|
||||
|
||||
/* debugging: check for gc */
|
||||
profile.print_gc();
|
||||
|
||||
var cycles = os.check_cycles();
|
||||
if (cycles) say(cycles);
|
||||
|
||||
|
||||
|
||||
profile.frame("app update");
|
||||
prosperon.appupdate(dt);
|
||||
profile.endframe();
|
||||
|
@ -1209,7 +1213,12 @@ prosperon.process = function process() {
|
|||
update_emitters(dt * game.timescale);
|
||||
profile.endframe();
|
||||
if (sim.mode === "step") sim.pause();
|
||||
}
|
||||
|
||||
profile.pushdata(profile.data.cpu.scripts, profile.now()-sst);
|
||||
sst = profile.now();
|
||||
|
||||
if (sim.mode === "play" || sim.mode === "step") {
|
||||
profile.frame("physics");
|
||||
physlag += dt;
|
||||
|
||||
|
@ -1219,11 +1228,14 @@ prosperon.process = function process() {
|
|||
prosperon.physupdate(physics.delta * game.timescale);
|
||||
}
|
||||
profile.endframe();
|
||||
profile.pushdata(profile.data.cpu.physics, profile.now()-sst);
|
||||
sst = profile.now();
|
||||
}
|
||||
|
||||
profile.frame("render");
|
||||
prosperon.window_render(window.size);
|
||||
prosperon.render();
|
||||
profile.pushdata(profile.data.cpu.render, profile.now()-sst);
|
||||
profile.endframe();
|
||||
profile.endframe();
|
||||
|
||||
|
|
|
@ -64,17 +64,20 @@ JSC_CCALL(imgui_menuitem,
|
|||
)
|
||||
|
||||
JSC_SCALL(imgui_plot,
|
||||
ImPlot::BeginPlot(str);
|
||||
script_call_sym(argv[1], 0, NULL);
|
||||
ImPlot::EndPlot();
|
||||
if (ImPlot::BeginPlot(str)) {
|
||||
script_call_sym(argv[1], 0, NULL);
|
||||
ImPlot::EndPlot();
|
||||
}
|
||||
)
|
||||
|
||||
#define PLOT_FN(NAME, FN, ADD) JSC_SCALL(imgui_##NAME, \
|
||||
#define PLOT_FN(NAME, FN, ADD, SHADED) JSC_SCALL(imgui_##NAME, \
|
||||
fill_plotdata(argv[1]); \
|
||||
ImPlot::FN(str, &plotdata[0].x, &plotdata[0].y, arrlen(plotdata), ADD 0, 0, sizeof(HMM_Vec2)); \
|
||||
bool shaded = js2boolean(argv[2]);\
|
||||
int flag = 0; \
|
||||
if (shaded) flag = SHADED; \
|
||||
ImPlot::FN(str, &plotdata[0].x, &plotdata[0].y, arrlen(plotdata), ADD flag, 0, sizeof(HMM_Vec2)); \
|
||||
) \
|
||||
|
||||
|
||||
static HMM_Vec2 *plotdata = NULL;
|
||||
|
||||
void fill_plotdata(JSValue v)
|
||||
|
@ -95,10 +98,24 @@ void fill_plotdata(JSValue v)
|
|||
}
|
||||
}
|
||||
|
||||
PLOT_FN(lineplot, PlotLine,)
|
||||
PLOT_FN(scatterplot, PlotScatter,)
|
||||
PLOT_FN(stairplot, PlotStairs,)
|
||||
PLOT_FN(digitalplot, PlotDigital,)
|
||||
PLOT_FN(lineplot, PlotLine,,ImPlotLineFlags_Shaded)
|
||||
PLOT_FN(scatterplot, PlotScatter,,0)
|
||||
PLOT_FN(stairplot, PlotStairs,,ImPlotStairsFlags_Shaded)
|
||||
PLOT_FN(digitalplot, PlotDigital,,0)
|
||||
static HMM_Vec3 *shadedata = NULL;
|
||||
|
||||
JSC_SCALL(imgui_shadedplot,
|
||||
arrsetlen(plotdata,js_arrlen(argv[1]));
|
||||
for (int i = 0; i < js_arrlen(argv[1]); i++) {
|
||||
HMM_Vec3 c;
|
||||
c.x = i;
|
||||
c.y = js2number(js_getpropidx(argv[1],i));
|
||||
c.z = js2number(js_getpropidx(argv[2],i));
|
||||
arrput(shadedata, c);
|
||||
}
|
||||
ImPlot::PlotShaded(str, &shadedata[0].x, &shadedata[0].y, &shadedata[0].z, arrlen(shadedata), 0, 0, sizeof(HMM_Vec3));
|
||||
)
|
||||
|
||||
JSC_SCALL(imgui_barplot,
|
||||
fill_plotdata(argv[1]);
|
||||
ImPlot::PlotBars(str, &plotdata[0].x, &plotdata[0].y, js_arrlen(argv[1]), js2number(argv[2]), 0, 0, sizeof(HMM_Vec2));
|
||||
|
@ -143,6 +160,15 @@ JSC_SCALL(imgui_textplot,
|
|||
ImPlot::PlotText(str, v.x, v.y);
|
||||
)
|
||||
|
||||
JSC_CCALL(imgui_inplot,
|
||||
HMM_Vec2 v = js2vec2(argv[0]);
|
||||
ImPlotRect lm = ImPlot::GetPlotLimits();
|
||||
if (v.x > lm.X.Min && v.x < lm.X.Max && v.y > lm.Y.Min && v.y < lm.Y.Max)
|
||||
return boolean2js(true);
|
||||
|
||||
return boolean2js(false);
|
||||
)
|
||||
|
||||
JSC_CCALL(imgui_plothovered,
|
||||
return boolean2js(ImPlot::IsPlotHovered());
|
||||
)
|
||||
|
@ -735,6 +761,7 @@ static const JSCFunctionListEntry js_imgui_funcs[] = {
|
|||
MIST_FUNC_DEF(imgui, plot2pixels, 1),
|
||||
MIST_FUNC_DEF(imgui, plotpos, 0),
|
||||
MIST_FUNC_DEF(imgui, plotlimits, 0),
|
||||
MIST_FUNC_DEF(imgui, inplot, 1),
|
||||
MIST_FUNC_DEF(imgui, window, 2),
|
||||
MIST_FUNC_DEF(imgui, menu, 2),
|
||||
MIST_FUNC_DEF(imgui, sameline, 1),
|
||||
|
@ -755,9 +782,11 @@ static const JSCFunctionListEntry js_imgui_funcs[] = {
|
|||
MIST_FUNC_DEF(imgui, checkbox, 2),
|
||||
MIST_FUNC_DEF(imgui, text, 1),
|
||||
MIST_FUNC_DEF(imgui, plot, 1),
|
||||
MIST_FUNC_DEF(imgui, lineplot, 2),
|
||||
MIST_FUNC_DEF(imgui, scatterplot, 2),
|
||||
MIST_FUNC_DEF(imgui, stairplot, 2),
|
||||
MIST_FUNC_DEF(imgui, lineplot, 3),
|
||||
MIST_FUNC_DEF(imgui, scatterplot, 3),
|
||||
MIST_FUNC_DEF(imgui, stairplot, 3),
|
||||
MIST_FUNC_DEF(imgui, digitalplot, 3),
|
||||
MIST_FUNC_DEF(imgui, shadedplot, 3),
|
||||
MIST_FUNC_DEF(imgui, barplot, 3),
|
||||
MIST_FUNC_DEF(imgui, pieplot, 5),
|
||||
MIST_FUNC_DEF(imgui, textplot, 2),
|
||||
|
@ -822,7 +851,7 @@ static int started = 0;
|
|||
|
||||
JSValue gui_init(JSContext *js)
|
||||
{
|
||||
simgui_desc_t sdesc = {0};
|
||||
simgui_desc_t sdesc = {};
|
||||
simgui_setup(&sdesc);
|
||||
|
||||
sgimgui_desc_t desc = {0};
|
||||
|
|
2
source/engine/thirdparty/imgui/imconfig.h
vendored
2
source/engine/thirdparty/imgui/imconfig.h
vendored
|
@ -111,7 +111,7 @@
|
|||
// Your renderer backend will need to support it (most example renderer backends support both 16/32-bit indices).
|
||||
// Another way to allow large meshes while keeping 16-bit indices is to handle ImDrawCmd::VtxOffset in your renderer.
|
||||
// Read about ImGuiBackendFlags_RendererHasVtxOffset for details.
|
||||
// #define ImDrawIdx unsigned int
|
||||
//#define ImDrawIdx unsigned int
|
||||
|
||||
//---- Override ImDrawCallback signature (will need to modify renderer backends accordingly)
|
||||
//struct ImDrawList;
|
||||
|
|
Loading…
Reference in a new issue