RIEMANAN

Benchmark created on


Setup

let theta = (t) =>
{
    return t/2*Math.log(t/2/Math.PI) - t/2 - Math.PI/8 + 1/48/t + 7/5760/t/t/t;
}

let terms = 0;
let logLookup = [];
let sqrtLookup = [];

Test runner

Ready to run.

Testing in
TestOps/sec
Lookup tables
for(let i = 1; i <= 25000; ++i)
{
    logLookup[i] = Math.log(i);
    sqrtLookup[i] = Math.sqrt(i);
}

for(let t = 0; t <= 100000; t += 0.1)
{
    let Z = 0;
    let fullN = Math.sqrt(t / (2*Math.PI));
    let N = Math.floor(fullN);
    let p = fullN - N;
    let th = theta(t);
    terms = N;
    for(let j = 1; j <= N; ++j)
    {
        Z += Math.cos(th - t*logLookup[j]) / sqrtLookup[j];
    }
}
ready
Raw maths
for(let t = 0; t <= 100000; t += 0.1)
{
    let Z = 0;
    let fullN = Math.sqrt(t / (2*Math.PI));
    let N = Math.floor(fullN);
    let p = fullN - N;
    let th = theta(t);
    terms = N;
    for(let j = 1; j <= N; ++j)
    {
        Z += Math.cos(th - t*Math.log(j)) / Math.sqrt(j);
    }
}
ready
Lookup tables adaptable
for(let t = 0; t <= 100000; t += 0.1)
{
    let Z = 0;
    let fullN = Math.sqrt(t / (2*Math.PI));
    let N = Math.floor(fullN);
    let p = fullN - N;
    let th = theta(t);
    for(let j = 1; j <= terms; ++j)
    {
        Z += Math.cos(th - t*logLookup[j]) / sqrtLookup[j];
    }
    for(let j = terms + 1; j <= N; ++j)
    {
        logLookup[j] = Math.log(j);
        sqrtLookup[j] = Math.sqrt(j);
        Z += Math.cos(th - t*logLookup[j]) / sqrtLookup[j];
    }
    terms = N;
}
ready
Lookup tables clean
for(let t = 0; t <= 100000; t += 0.1)
{
    let Z = 0;
    let fullN = Math.sqrt(t / (2*Math.PI));
    let N = Math.floor(fullN);
    let p = fullN - N;
    let th = theta(t);
    for(let j = terms + 1; j <= N; ++j)
    {
        logLookup[j] = Math.log(j);
        sqrtLookup[j] = Math.sqrt(j);
    }
    terms = N;
    for(let j = 1; j <= N; ++j)
    {
        Z += Math.cos(th - t*logLookup[j]) / sqrtLookup[j];
    }
}
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.