bench: replace stack allocation with dynamic allocation
fix(math/strided/special/dfloor): replace stack allocation with dynamic allocation in benchmark
Replace fixed-size array declarations with dynamic memory allocation in the dfloor benchmark to prevent segmentation faults when processing large input sizes. The benchmark previously failed with segmentation faults for arrays with 1,000,000 elements due to stack memory limitations.
Changes:
- Replace stack-allocated arrays with malloc/free for x and y arrays
- Add proper error handling for memory allocation failures
- Add memory cleanup to prevent memory leaks
- Add error checking in main benchmark loop
Fixes: #7224
- [x] Read, understood, and followed the contributing guidelines
:wave: Hi there! :wave:
And thank you for opening your first pull request! We will review it shortly. :runner: :dash:
Getting Started
- Please read our contributing guidelines if you haven't already.
- For development guidance, refer to the development guide.
Next Steps
- A project maintainer will approve GitHub Actions workflows for your PR.
- All CI checks must pass before your submission can be fully reviewed.
- You'll need to address any failures in linting or unit tests.
Running Tests Locally
You can use make to run any of the CI commands locally from the root directory of the stdlib repository:
# Run tests for all packages in the math namespace:
make test TESTS_FILTER=".*/@stdlib/math/.*"
# Run benchmarks for a specific package:
make benchmark BENCHMARKS_FILTER=".*/@stdlib/math/base/special/sin/.*"
If you haven't heard back from us within two weeks, please ping us by tagging the "reviewers" team in a comment on this PR.
If you have any further questions while waiting for a response, please join our Gitter channel to chat with project maintainers and other community members.
We appreciate your contribution!
Documentation Links
Hello! Thank you for your contribution to stdlib.
We noticed that the contributing guidelines acknowledgment is missing from your pull request. Here's what you need to do:
-
Please read our contributing guidelines.
-
Update your pull request description to include this checked box:
- [x] Read, understood, and followed the [contributing guidelines](https://github.com/stdlib-js/stdlib/blob/develop/CONTRIBUTING.md)
This acknowledgment confirms that you've read the guidelines, which include:
- The developer's certificate of origin
- Your agreement to license your contributions under the project's terms
We can't review or accept contributions without this acknowledgment.
Thank you for your understanding and cooperation. We look forward to reviewing your contribution!
Coverage Report
| Package | Statements | Branches | Functions | Lines |
|---|---|---|---|---|
| math/strided/special/dfloor | $\color{green}374/374$ $\color{green}+100.00\%$ |
$\color{green}15/15$ $\color{green}+100.00\%$ |
$\color{green}4/4$ $\color{green}+100.00\%$ |
$\color{green}374/374$ $\color{green}+100.00\%$ |
The above coverage report was generated for the changes in this PR.
@navyansh007 Would you mind updating this PR to match the dynamic memory allocation changes in this commit: https://github.com/stdlib-js/stdlib/commit/2c9f492d8e15e860aa56f9d3b5b3845191480700? Cheers!
Hey @kgryte,
I have updated the malloc statements in the code and changed them to match the way they are written in the commit you mentioned. I request you to have a look at that. Feel free to let me know if any further changes are required.