The existing implementation of stumpless_get_prival_string makes use of snprintf to build the resulting string, but a simple memcpy scheme would likely be more performant. This change is to refactor the function to do this, and verify that performance has improved.
General Approach
There are a few details left out of the following approach, for you to fill in as you encounter them. If you find you need help, please ask here or on the project gitter and someone can help you get past the stumbling block.
Before you make any changes, make sure that you can run the performance tests, specifically the GetPrivalString benchmark. Make sure that you can collect performance both before and after you implement your change. You should see Time/CPU cycles decrease as a result - if you do not, review your implementation and find out why. You can find details on running the performance benchmarks in stumpless in the docs/benchmark.md documentation.
The change itself is straightforward - the function in question is in src/prival.c.
Once you have this, make your changes and make sure that performance improves as expected! The test suites should continue to pass and coverage should not decrease as a result of your changes - you may need to add more tests for the refactored function to test/function/prival.cpp improve coverage depending on your implementation.
EDIT: Originally this issue stated that memory allocations would decrease as part of this change, but as pointed out by @Caselhos this is not true - the change only affects CPU usage.
The existing implementation of
stumpless_get_prival_string
makes use ofsnprintf
to build the resulting string, but a simplememcpy
scheme would likely be more performant. This change is to refactor the function to do this, and verify that performance has improved.General Approach
There are a few details left out of the following approach, for you to fill in as you encounter them. If you find you need help, please ask here or on the project gitter and someone can help you get past the stumbling block.
Before you make any changes, make sure that you can run the performance tests, specifically the
GetPrivalString
benchmark. Make sure that you can collect performance both before and after you implement your change. You should see Time/CPU cycles decrease as a result - if you do not, review your implementation and find out why. You can find details on running the performance benchmarks in stumpless in the docs/benchmark.md documentation.The change itself is straightforward - the function in question is in
src/prival.c
.Once you have this, make your changes and make sure that performance improves as expected! The test suites should continue to pass and coverage should not decrease as a result of your changes - you may need to add more tests for the refactored function to
test/function/prival.cpp
improve coverage depending on your implementation.EDIT: Originally this issue stated that memory allocations would decrease as part of this change, but as pointed out by @Caselhos this is not true - the change only affects CPU usage.