Run Save Upload File Fullscreen About
<span id="result">Warning: Your browser may not respond during compute time!</span><br />
<input type="button" id="compute" value="Compute" onclick="javascript:displayJSBogoMIPS();" />

			
function displayJSBogoMIPS() {
    document.getElementById("compute").style.display = "none";
    setTimeout(function() {
        document.getElementById("result").innerHTML = computeJSBogoMIPS() + " BogoMIPS in JavaScript.";
    }, 100);
}

function computeJSBogoMIPS() {
    // Initializing some variables
    var iterations = 0, aBool, compensationTest, startTest, endTest;
    
    // Get the first time to try to calculate the time of an iteration
    startTest = performance.now();
    
    // Do some stuff
    iterations++;
    compensationTest = performance.now();
    aBool = start - compensationTest < 1000;
    
    // Get the difference
    endTest = performance.now();
    compensationTest = endTest - startTest; // Here we have the time of an what will be doing in the loop below
    
    // Some others variables that we'll need
    var start, end, current = 0;
    iterations = 0;
    
    // Starting time
    start = performance.now();
    
    // Loop
    while (current - start < 1000) {
        iterations++;
        current = performance.now();
    }
    
    // This is the time where we increment, get the time and check the condition
    var lost = iterations * compensationTest;
    
    // This is the percentage of time lost
    var lostPart = lost / 1000;
    
    // And finaly this is the number of iterations we can do without the lost time
    return (iterations + (iterations * lostPart / (1000 - lostPart))) / 1e6;
    
}
JavaScript Console