This PR adds support for asynchronously collecting timings, and for collecting timings from AsyncWorkers for AsyncTasks.
The implemented API allows custom collect callbacks to be registered, which allows plugins to include custom thread timings in timings reports. This is necessary because other threads' timings records can't be directly accessed from the main thread.
Relevant issues
Closes #6166
Changes
API changes
TimingsHandler::printTimings() is now deprecated
Added getToggleCallbacks(), getResetCallbacks() and getCollectCallbacks() to TimingsHandler
Behavioural changes
Timings reports now include AsyncTask timings.
Timings may now take slightly longer to generate as the report generator has to wait for other threads to respond.
Timings report version 3 is now used. This tells the timings viewer to use the ThreadId part of timer group names to namespace timer IDs (necessary since timer IDs could otherwise collide between different threads).
Backwards compatibility
Should be fully backwards compatible
Follow-up
Requires translations:
Name
Value in eng.ini
N/A
Compiling timings report
Tests
I tested this PR by doing the following (tick all that apply):
[ ] Writing PHPUnit tests (commit these in the tests/phpunit folder)
[x] Playtesting using a Minecraft client (provide screenshots or a video)
[ ] Writing a test plugin (provide the code and sample output)
There are some unrelated changes in the PR which I made to facilitate this feature, such as Promise::all() supporting 0 promises. These should be separated before merging.
Introduction
This PR adds support for asynchronously collecting timings, and for collecting timings from AsyncWorkers for AsyncTasks.
The implemented API allows custom collect callbacks to be registered, which allows plugins to include custom thread timings in timings reports. This is necessary because other threads' timings records can't be directly accessed from the main thread.
Relevant issues
Closes #6166
Changes
API changes
TimingsHandler::printTimings()
is now deprecatedgetToggleCallbacks()
,getResetCallbacks()
andgetCollectCallbacks()
toTimingsHandler
Behavioural changes
ThreadId
part of timer group names to namespace timer IDs (necessary since timer IDs could otherwise collide between different threads).Backwards compatibility
Should be fully backwards compatible
Follow-up
Requires translations:
Compiling timings report
Tests
I tested this PR by doing the following (tick all that apply):
tests/phpunit
folder)Samples
This requires a version of the timings viewer including the following commit: https://github.com/pmmp/timings/commit/13cefa6279ee8866dc584b9a7977a9c09cecd732
An example report can be viewed here: https://timings.pmmp.io/?id=330357