editor: disable the profiler by default

This commit is contained in:
Ammar Ahmed
2026-08-25 18:37:12 +05:00
parent 2d3a4f544d
commit 21606dc43e
3 changed files with 10 additions and 11 deletions

View File

@@ -197,10 +197,9 @@ export function installProfilerGlobals() {
};
(globalThis as unknown as Record<string, unknown>).editorProfiler = api;
console.log(
profiler.enabled
? "[profiler] on by default. window.editorProfiler.print() for a report, .disable() to turn off."
: "[profiler] off. window.editorProfiler.enable() to turn it back on."
);
if (profiler.enabled)
console.log(
"[profiler] active. window.editorProfiler.print() for a report, .disable() to turn off."
);
return api;
}

View File

@@ -29,15 +29,15 @@ beforeEach(() => {
});
describe("profiler", () => {
test("is enabled by default", () => {
test("is disabled by default", () => {
globalThis.localStorage?.clear();
expect(new Profiler().enabled).toBe(true);
expect(new Profiler().enabled).toBe(false);
});
test("stays disabled across reloads once turned off", () => {
test("stays enabled across reloads once turned on", () => {
globalThis.localStorage?.clear();
new Profiler().disable();
expect(new Profiler().enabled).toBe(false);
new Profiler().enable();
expect(new Profiler().enabled).toBe(true);
});
test("records nothing while disabled", () => {

View File

@@ -18,7 +18,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
const STORAGE_KEY = "nn:profiler";
const DEFAULT_ENABLED = true;
const DEFAULT_ENABLED = false;
const DEFAULT_MAX_SAMPLES = 4000;
const DEFAULT_MAX_TIMELINE = 4000;