diff --git a/scripts/debug.js b/scripts/debug.js index 8afacad..f41babc 100644 --- a/scripts/debug.js +++ b/scripts/debug.js @@ -211,16 +211,6 @@ debug.api.print_doc = function(name) return mdoc; } -debug.log = {}; - -debug.log.time = function(fn, name, avg=0) -{ - debug.log.time[name] ??= []; - var start = profile.now(); - fn(); - debug.log.time[name].push(profile.now()-start); -} - debug.kill = function() { assert = function() {}; diff --git a/scripts/engine.js b/scripts/engine.js index cfbf4a7..cd8a9c2 100644 --- a/scripts/engine.js +++ b/scripts/engine.js @@ -652,6 +652,8 @@ prosperon.touchrelease = function (touches) {}; prosperon.touchmove = function (touches) {}; prosperon.clipboardpaste = function (str) {}; prosperon.quit = function () { + if (profile.disabled) return; + say("===START CACHE REPORTS===\n"); for (var i in profile.report_cache) { say(profile.printreport(profile.report_cache[i],i)); @@ -662,10 +664,6 @@ prosperon.quit = function () { say("\n"); profile.print_cpu_instr(); - - console.info("QUITTING"); - for (var i in debug.log.time) - say(debug.log.time[i].map((x) => profile.ms(x))); }; window.size = [640, 480]; diff --git a/scripts/profile.js b/scripts/profile.js index c654029..639be99 100644 --- a/scripts/profile.js +++ b/scripts/profile.js @@ -176,3 +176,12 @@ profile.printreport = function (cache, name) { return report; }; + +var null_fn = function(){}; +profile.disable = function() +{ + profile.gather_stop(); + profile.frame = null_fn; + profile.endframe = null_fn; + profile.disabled = true; +} \ No newline at end of file diff --git a/scripts/render.js b/scripts/render.js index 8fea0ba..527cf19 100644 --- a/scripts/render.js +++ b/scripts/render.js @@ -194,7 +194,7 @@ render.make_shader = function(shader) } } - profile.report(st, `CACHE make shader from ${file}`); + profile.addreport("shader [cached]", file, st); var shaderobj = json.decode(io.slurp(writejson)); var obj = shaderobj[os.sys()]; obj.pipe = render.pipeline(obj); @@ -310,7 +310,7 @@ render.make_shader = function(shader) compiled.files = files; io.slurpwrite(writejson, json.encode(compiled)); - profile.report(st, `make shader from ${file}`); + profile.addreport('shader', file, st); var obj = compiled[os.sys()]; obj.pipe = render.pipeline(obj); diff --git a/source/engine/font.c b/source/engine/font.c index bc05183..fd39486 100644 --- a/source/engine/font.c +++ b/source/engine/font.c @@ -104,7 +104,6 @@ struct sFont *MakeFont(const char *fontfile, int height) { newfont->descent = descent*emscale; newfont->linegap = linegap*emscale; newfont->linegap = ((newfont->ascent - newfont->descent) - newfont->linegap); - printf("newfont : %g, %g, %g\n", newfont->ascent, newfont->descent, newfont->linegap); newfont->texture = malloc(sizeof(texture)); newfont->texture->id = sg_make_image(&(sg_image_desc){ diff --git a/source/engine/jsffi.c b/source/engine/jsffi.c index 12c7d40..b868451 100644 --- a/source/engine/jsffi.c +++ b/source/engine/jsffi.c @@ -1327,10 +1327,15 @@ JSC_CCALL(profile_gather_rate, JS_SetInterruptRate(js2number(argv[0])); ) +JSC_CCALL(profile_gather_stop, + JS_SetInterruptHandler(rt,NULL,NULL,10000); +) + static const JSCFunctionListEntry js_profile_funcs[] = { MIST_FUNC_DEF(profile,now,0), MIST_FUNC_DEF(profile,gather,2), - MIST_FUNC_DEF(profile,gather_rate,1) + MIST_FUNC_DEF(profile,gather_rate,1), + MIST_FUNC_DEF(profile,gather_stop,0), }; JSC_SCALL(io_exists, ret = boolean2js(fexists(str)))