fictioneer/js/dev-tools.min.js
2024-12-06 17:38:32 +01:00

1 line
595 B
JavaScript

async function fcn_benchmarkAjax(e=1,n={},t=null,o={},r="get"){let s=0;console.log(`Starting benchmark with ${e} AJAX requests...`);for(let c=0;c<e;c++){const e=performance.now();try{"get"===r?await FcnUtils.aGet(n,t,o):await FcnUtils.aPost(n,t,o),s+=performance.now()-e}catch(e){console.error("Error during AJAX request:",e)}}const c=s/e;return console.log(`Finished benchmarking. Average AJAX response time over ${e} requests: ${c.toFixed(2)} ms`),c}function fcn_printAjaxResponse(e,n="get"){"get"===n?FcnUtils.aGet(e).then((e=>{console.log(e)})):FcnUtils.aPost(e).then((e=>{console.log(e)}))}