Skip to content

Instantly share code, notes, and snippets.

@Attackmonkey
Created July 13, 2017 10:37
Show Gist options
  • Save Attackmonkey/8ffbfd36276129e19527d48891d3e96a to your computer and use it in GitHub Desktop.
Save Attackmonkey/8ffbfd36276129e19527d48891d3e96a to your computer and use it in GitHub Desktop.
Example JS to Call Test Methods of Benchmark Controller. Call these on a button click event!
//test each method, synchronously
var promises = [];
promises.push($.ajax({
url: '/umbraco/surface/benchmark/AllChildrenFromNode',
success: function (resp) {
var num = parseFloat(resp);
console.log('All By Direct Children: ' + num);
},
async: false
}));
promises.push($.ajax({
url: '/umbraco/surface/benchmark/allbybadlinq',
success: function (resp) {
var num = parseFloat(resp);
console.log('All By Bad LINQ Query: ' + num);
},
async: false
}));
//repeat as many times as necessary
//if you want to spam the methods to test under load, use something like this:
for (x = 0; x < 1000; x++)
{
promises.push($.ajax({
url: '/umbraco/surface/benchmark/SearchWithLinq?loop=true',
success: function (resp) {
var num = parseFloat(resp);
total += num;
},
async: true
}));
}
//call this to run AFTER all operations have completed
$.when.apply($, promises).then(function () {
console.log('Benchmarks complete');
btn.text(oldText);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment