JSFiddle - React, Tailwind, and code Playground
JavaScript
var results = "";
var runs = 10000000;
var x = 10;
var ops = [];
ops.push({ name: "addition",
run: function(){x+3;}});
ops.push({ name: "subtraction",
run: function(){x-3;}});
ops.push({ name: "comparision",
run: function(){x===3;}});
ops.push({ name: "multiplication",
run: function(){x*3;}});
ops.push({ name: "division",
run: function(){x/3;}});
ops.push({ name: "modulus",
run: function(){x%3;}});
ops.push({ name: "exp",
run: function(){Math.exp(x);}});
ops.push({ name: "sqrt",
run: function(){Math.sqrt(x);}});
ops.push({ name: "sin",
run: function(){Math.sin(x);}});
ops.push({ name: "cos",
run: function(){Math.cos(x);}});
ops.push({ name: "asin",
run: function(){Math.asin(x);}});
ops.push({ name: "pow",
run: function(){Math.pow(x,3);}});
ops.forEach(function(op){
var start = new Date().getTime();
for (i = 0; i < runs; ++i) {
op.run();
}
var end = new Date().getTime();
var time = end - start;
results += op.name+": "+time+"\n";
});
alert(results);