fictioneer/js/dev-tools.min.js

1 line
749 B
JavaScript
Raw Permalink Normal View History

2024-12-11 16:44:48 +01:00
async function fcn_benchmarkAjax(e=1,t={},n=null,o={},r="get"){let s=0;console.log(`Starting benchmark with ${e} AJAX requests...`);try{"get"===r?await FcnUtils.aGet(t,n,o):await FcnUtils.aPost(t,n,o)}catch(e){console.error("Error during warm-up request:",e)}for(let c=0;c<e;c++){const e=performance.now();try{"get"===r?await FcnUtils.aGet(t,n,o):await FcnUtils.aPost(t,n,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,{method:t="get",url:n=null}={}){"get"===t?FcnUtils.aGet(e,n).then((e=>{console.log(e)})):FcnUtils.aPost(e,n).then((e=>{console.log(e)}))}