Toggle navigation
MeasureThat.net
Create a benchmark
Tools
Feedback
FAQ
Register
Log In
Run results for:
Native XHR vs Fetch (async/await - try/catch)
XHR and Fetch benchmark with and without async/await and try/catch.
Go to the benchmark
Embed
Embed Benchmark Result
Run details:
User agent:
Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36
Browser:
Chrome 125
Operating system:
Linux
Device Platform:
Desktop
Date tested:
2 years ago
Test name
Executions per second
Native XHR
6995.8 Ops/sec
Native XHR (try/catch)
8131.8 Ops/sec
Fetch (promise)
7700.0 Ops/sec
Fetch (async/await)
7173.8 Ops/sec
Fetch (async/await - try/catch)
7728.8 Ops/sec
Script Preparation code:
function showResult(data) { //console.log(data); } var newUrl = "https://www.googleapis.com/discovery/v1/apis";
Tests:
Native XHR
try { var xhr = new XMLHttpRequest(); xhr.open("GET", newUrl, true); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { showResult(xhr); } } xhr.send(); } catch (error) { console.log(error); } finally { // done }
Native XHR (try/catch)
var xhr = new XMLHttpRequest(); xhr.open("GET", newUrl, true); xhr.onreadystatechange = function() { if (xhr.readyState === 4) { showResult(xhr); } } xhr.send();
Fetch (promise)
var request = fetch(newUrl).then(showResult);
Fetch (async/await)
var testThis = async function() { var response = await fetch(newUrl); var data = await response.json(); return data; } testThis().then(function(data){ showResult(data); });
Fetch (async/await - try/catch)
var testThis = async function() { try { var response = await fetch(newUrl); var data = await response.json(); } catch (error) { console.log(error); } finally { return data; } } testThis().then(function(data){ showResult(data); });