Toggle navigation
MeasureThat
.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Test: React useCallback vs notUseCallback
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Safari/537.36
Browser:
Chrome 137
Operating system:
Windows
Device Platform:
Desktop
Date tested:
one year ago
With useCallback
1.5M/s
Without useCallback
990K/s
View exact numbers
Test name
Executions per second
✓
With useCallback
1,546,779 Ops/sec
Without useCallback
989,866 Ops/sec
HTML Preparation code:
<!doctype html> <html> <head> <title>This is the title of the webpage!</title> </head> <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.13.1/umd/react-dom.production.min.js"></script> <div id="root"></div> </body> </html>
Script Preparation code:
function ComponentWithOutUseCallback() { const testFunction = (evt) => evt.preventDefault() return React.createElement('button', {onClick: testFunction}, 'Test click'); } function ComponentWithUseCallback() { const testFunction = React.useCallback(evt => evt.preventDefault(), []); return React.createElement('button', {onClick: testFunction}, 'Test click'); }
Tests:
Without useCallback
ReactDOM.render(React.createElement(ComponentWithOutUseCallback), document.getElementById('root'))
With useCallback
ReactDOM.render(React.createElement(ComponentWithUseCallback), document.getElementById('root'))