mojira.dev
MCPE-230313

Script profiler captures incorrect self-time values

Steps to reproduce the issue:

  1. Launch Minecraft Bedrock Edition

  2. Join a local world with any pack that contains scripting content

  3. Use /script profiler start

  4. Wait a few seconds

  5. Use /script profiler stop

  6. Follow the output path in the chat to find where the cpuprofile file is stored

  7. Open the latest .cpuprofile file in Visual Studio Code with the Flame Chart Visualizer for JavaScript Profiles extension installed

  8. Review the results (click on the flame on the top right to toggle the flame graph)

Expected result:
The self-time should only benchmark how long a function takes to execute.

Executing 1 native (@minecraft/server) function a tick should result in a self-time of <1ms.

Actual result:
The self-time of a native (@minecraft/server) function captures more than just the own execution time. The self-time seems to always contain 1 function with the time until the current tick ends (40-50ms). This behavior is visible when looking at the flame graph.

Executing 1 native (@minecraft/server) function a tick shouldn’t result in a self-time of ~50ms. My test result shows 50ms for 1 simple Player::sendMessage per tick. The PlayerSpawnAfterEvent which is used to start the runInterval is also 50ms. So it looks like the profiler stops the captured time when the current tick ends and not when the function actually is done.

Additional Informations:
I attached my test files & the results.

  • The main.js file is my scripting file

    • Start a run interval on player spawn

    • Send the spawned player a message containing the current tick every tick

  • The profile....cpuprofile is the resulting .cpuprofile which contains the benchmark

  • The 2 screenshots visualise the .cpuprofile file when opened with the flame graph extension

At the start of the year 2025 (I think march) the profiler worked as expected.

Attachments

Comments 0

No comments.

Valerian Ewert

(Unassigned)

Unconfirmed

Windows

11

1.21.120

Retrieved