Skip to content

[FEATURE] Show per-script hook execution time for performance profiling #3620

@luginf

Description

@luginf

Is your feature request related to a problem? Please describe.

When multiple scripts are installed, it is currently impossible to identify which one is causing slowdowns without disabling them one by one. A lightweight profiling mechanism would make it much easier to diagnose performance issues.

Describe the solution you'd like

Wrap each scripting hook invocation (e.g. noteToMarkdownHtmlHook, handleNoteTextFileNameHook, customActionInvoked, …) with a QElapsedTimer on the C++ side. When execution time exceeds a configurable threshold (or unconditionally in a debug/profiling mode), log a warning such as:

[script profiler] my-script :: noteToMarkdownHtmlHook took 42 ms

Optionally, expose an aggregated summary (total time per script per hook) in the script settings panel or in the log window.

  • noteToMarkdownHtmlHook is called on every keystroke in live preview — even a mildly expensive script causes visible lag.
  • Users with many scripts installed have no way to pinpoint the offending one without tedious manual bisection.
  • The change is self-contained: a QElapsedTimer around each existing hook dispatch call, with a threshold guard to avoid log noise.

Describe alternatives you've considered

  • A QOwnNotes script cannot profile other scripts: the scripting API exposes no inter-script communication or CPU metrics.
  • OS-level profiling (perf, valgrind) works but cannot attribute time to individual scripts by name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions