Use ring buffer for the SimProfiler#3304
Conversation
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Replace O(N) erase(begin())+push_back() per frame with O(1) indexed writes using a pointer.
f7b3cf8 to
9c72c3f
Compare
|
Thanks for the PR! We have not been very good with writing tests for the studio components, perhaps you could kick this off by adding a simple one for the SimProfiler. You could make sure it passes with and without your change e.g., by implementing the test in a first commit and doing the refactor in the next one. |
|
@okmatija Thank you for the review! Contracts covering both before and after the change:
Contracts focused only on the behavior after this change:
Which scope would you prefer? |
|
We don't want to maintain detailed tests I think, just some basic sanity checking is enough IMO. Also, looking at the API again I think we don't really have a useful public function we can use to implement the tests (we don't really want to check private implmeentation details like where
The summary data may be useful in the UI somewhere. WDYT @haroonq ? |
Update()callederase(begin())+push_back()on 11 vectors every frame, O(N) per buffer. Replace with ahead_write cursor and direct indexed writes (buf[head_] = val), advancing the cursor modulo 200 at the end of each update. Passhead_as ImPlot'soffsetparameter so the circular buffer renders correctly without data movement.