a^n vs n times of a (v2)

Revision 2 of this benchmark created on


Description

1 + a + a^2 + ... + a^n

Setup

const a = 17
const n = 100

Test runner

Ready to run.

Testing in
TestOps/sec
O(n)
let result = 1
let power = 1

for (let i = 1; i <= n; i++){
    power *= a 
    result += power
}
ready
O(n^2)
let result = 1

for (let i = 1; i <= n; i++){
    result += a ** i
}
ready

Revisions

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