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 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/137.0.0.0 Mobile Safari/537.36 EdgA/137.0.0.0
Browser:
Chrome Mobile 137
Operating system:
Android
Device Platform:
Mobile
Date tested:
one year ago
Test name
Executions per second
Native XHR
1623.9 Ops/sec
Native XHR (try/catch)
1798.8 Ops/sec
Fetch (promise)
1404.8 Ops/sec
Fetch (async/await)
1510.3 Ops/sec
Fetch (async/await - try/catch)
1535.3 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); });