Steps to reproduce the issue:
- Launch Minecraft Bedrock Edition 
- Join a local world with any pack that contains scripting content 
- Use - /script profiler start
- Wait a few seconds 
- Use - /script profiler stop
- Follow the output path in the chat to find where the cpuprofile file is stored 
- Open the latest - .cpuprofilefile in- Visual Studio Codewith the- Flame Chart Visualizer for JavaScript Profilesextension installed
- 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.jsfile 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....cpuprofileis the resulting- .cpuprofilewhich contains the benchmark
- The 2 screenshots visualise the - .cpuprofilefile 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.
