src/ecc/key_utils.js
function cpuEntropy(cpuEntropyBits = 128) {
    let collected = [];
    let lastCount = null;
    let lowEntropySamples = 0;
    while(collected.length < cpuEntropyBits) {
        const count = floatingPointCount();
        if(lastCount != null) {
            const delta = count - lastCount;
            if(Math.abs(delta) < 1) {
                lowEntropySamples++;
                continue;
            }
            // how many bits of entropy were in this sample
            const bits = Math.floor(log2(Math.abs(delta)) + 1);
            if(bits < 4) {
                if(bits < 2) {
                    lowEntropySamples++;
                }
                continue;
            }
            collected.push(delta);
        }
        lastCount = count;
    }
    if(lowEntropySamples > 10) {
        const pct = Number(lowEntropySamples / cpuEntropyBits * 100).toFixed(2);
        // Is this algorithm getting inefficient?
        console.warn(`WARN: ${pct}% low CPU entropy re-sampled`);
    }
    return collected;
}
function cpuEntropy(cpuEntropyBits = 128) {
    let collected = [];
    let lastCount = null;
    let lowEntropySamples = 0;
    while(collected.length < cpuEntropyBits) {
        const count = floatingPointCount();
        if(lastCount != null) {
            const delta = count - lastCount;
            if(Math.abs(delta) < 1) {
                lowEntropySamples++;
                continue;
            }
            // how many bits of entropy were in this sample
            const bits = Math.floor(log2(Math.abs(delta)) + 1);
            if(bits < 4) {
                if(bits < 2) {
                    lowEntropySamples++;
                }
                continue;
            }
            collected.push(delta);
        }
        lastCount = count;
    }
    if(lowEntropySamples > 10) {
        const pct = Number(lowEntropySamples / cpuEntropyBits * 100).toFixed(2);
        // Is this algorithm getting inefficient?
        console.warn(`WARN: ${pct}% low CPU entropy re-sampled`);
    }
    return collected;
}
function cpuEntropy ( cpuEntropyBits = 128 ) { let collected = [ ] ; let lastCount = null ; let lowEntropySamples = 0 ; while ( collected . length < cpuEntropyBits ) { const count = floatingPointCount ( ) ; if ( lastCount != null ) { const delta = count - lastCount ; if ( Math . abs ( delta ) < 1 ) { lowEntropySamples ++ ; continue ; } // how many bits of entropy were in this sample const bits = Math . floor ( log2 ( Math . abs ( delta ) ) + 1 ) ; if ( bits < 4 ) { if ( bits < 2 ) { lowEntropySamples ++ ; } continue ; } collected . push ( delta ) ; } lastCount = count ; } if ( lowEntropySamples > 10 ) { const pct = Number ( lowEntropySamples / cpuEntropyBits * 100 ) . toFixed ( 2 ) ; // Is this algorithm getting inefficient? console . warn ( ` ${ pct } ` ) ; } return collected ; }
This runs in just under 1 second and ensures a minimum of cpuEntropyBits
bits of entropy are gathered.

Based on more-entropy. @see https://github.com/keybase/more-entropy/blob/master/src/generator.iced

@arg {number} [cpuEntropyBits = 128]
@return {array} counts gathered by measuring variations in the CPU speed during floating point operations.
This runs in just under 1 second and ensures a minimum of cpuEntropyBits bits of entropy are gathered .