Profiling Vim9 scripts

55 views
Skip to first unread message

Lifepillar

unread,
May 3, 2025, 4:33:06 PMMay 3
to vim...@googlegroups.com
What is the status of profiling for Vim9 scripts?

I'm trying to profile a somewhat complex script using

profile start test.prof
profile func *

and getting:

E1271: Compiling closure without context: <lambda>65

Using a more restrictive pattern (e.g., *Foo*, where Foo matches the
name of some method) does not give errors, but the profile is empty.

I do get a profile with `profile! file path/to/some/script.vim` if
I source the script. But I am interested in profiling code from imported
scripts. Is that possible at all?

Life.

Lifepillar

unread,
Jun 3, 2025, 4:08:45 AMJun 3
to vim...@googlegroups.com
On 2025-05-03, Lifepillar <lifep...@lifepillar.me> wrote:
> What is the status of profiling for Vim9 scripts?
>
> I'm trying to profile a somewhat complex script using
>
> profile start test.prof
> profile func *
>
> and getting:
>
> E1271: Compiling closure without context: <lambda>65

Follow-up: skipping `profile func *` appears to work. That is, after:

1. `profile start test.prof`,
2. execute whatever Vim9 script,
3. `profile stop`,

I get proper profile results.

Life.

Lifepillar

unread,
Jun 3, 2025, 6:46:35 AMJun 3
to vim...@googlegroups.com
On 2025-06-03, Lifepillar <lifep...@lifepillar.me> wrote:
> On 2025-05-03, Lifepillar <lifep...@lifepillar.me> wrote:
>> What is the status of profiling for Vim9 scripts?
>>
>> I'm trying to profile a somewhat complex script using
>>
>> profile start test.prof
>> profile func *
>>
>> and getting:
>>
>> E1271: Compiling closure without context: <lambda>65
>
> Follow-up: skipping `profile func *` appears to work.

Mmh, not that's incorrect. This is how I actually make it work:

1. profile start test.prof
2. profile func *
3. Execute whatever Vim9 script. At this point, I get E1271.
4. Source the offending script (the one defining <lambda>65).
5. Re-execute whatever Vim9 script.
6. profile stop.

Step (4) is what fixes E1271.

The total times are bonkers ("functions sorted on total time" and
"functions sorted on self time"), but the profile of each individual
function looks reasonable enough.

Life.

Reply all
Reply to author
Forward
0 new messages