Measuring compilation speed
Fibonacci(3)
.
The code uses big.Int/BigInteger
because Fibonacci numbers get large fast and if we
want to generate f100000
and see if it works int
s
range is not big enough. The Map
is for speeding things up by
calculating f12
etc. only once.
public static BigInteger f3(Map m) {
if (m.containsKey(3)) {
return m.get(3);
} else {
BigInteger r = M1.f2(m).add(M1.f1(m));
m.put(3, r);
return r;
}
}
func F3(m map[int]*big.Int) *big.Int {
val, ok := m[3]
if ok {
return val
} else {
r := big.NewInt(0)
r.Add(F2(m), F1(m))
m[3] = r
return r
}
}
stephan@amazingcto.com
Compiler | Func | LOC | Time | Loc/s | CPU | Cores | Drive | RAM | Version | Vendor | OS |
---|---|---|---|---|---|---|---|---|---|---|---|
Go | 10000 | 111098 | 3.85 | 28857 | 3900x | 12P / 0E | WD_BLACK SN850 | 32 | 19.3 | WSL | |
Go | 20000 | 222198 | 8.04 | 27637 | 3900x | 12P / 0E | WD_BLACK SN850 | 32 | 19.3 | WSL | |
Go | 30000 | 333298 | 14.65 | 22751 | 3900x | 12P / 0E | WD_BLACK SN850 | 32 | 19.3 | WSL | |
Go | 40000 | 444398 | 17.01 | 26126 | 3900x | 12P / 0E | WD_BLACK SN850 | 32 | 19.3 | WSL | |
Go | 50000 | 555498 | 22.49 | 24700 | 3900x | 12P / 0E | WD_BLACK SN850 | 32 | 19.3 | WSL | |
Go | 60000 | 666598 | 27.93 | 23867 | 3900x | 12P / 0E | WD_BLACK SN850 | 32 | 19.3 | WSL | |
Go | 70000 | 777698 | 33.99 | 22880 | 3900x | 12P / 0E | WD_BLACK SN850 | 32 | 19.3 | WSL | |
Go | 80000 | 888798 | 42.33 | 20997 | 3900x | 12P / 0E | WD_BLACK SN850 | 32 | 19.3 | WSL | |
Go | 90000 | 999898 | 47.19 | 21189 | 3900x | 12P / 0E | WD_BLACK SN850 | 32 | 19.3 | WSL | |
Go | 100000 | 1110998 | 54.74 | 20296 | 3900x | 12P / 0E | WD_BLACK SN850 | 32 | 19.3 | WSL | |
Go | 10000 | 111098 | 8.2 | 13549 | 3900x | 12P / 0E | Samsung SSD 970 EVO Plus | 32 | 19.3 | WSL | |
Go | 20000 | 222198 | 16.57 | 13410 | 3900x | 12P / 0E | Samsung SSD 970 EVO Plus | 32 | 19.3 | WSL | |
Go | 30000 | 333298 | 26.35 | 12649 | 3900x | 12P / 0E | Samsung SSD 970 EVO Plus | 32 | 19.3 | WSL | |
Go | 40000 | 444398 | 33.79 | 13152 | 3900x | 12P / 0E | Samsung SSD 970 EVO Plus | 32 | 19.3 | WSL | |
Go | 50000 | 555498 | 42.03 | 13217 | 3900x | 12P / 0E | Samsung SSD 970 EVO Plus | 32 | 19.3 | WSL | |
Go | 60000 | 666598 | 50.81 | 13119 | 3900x | 12P / 0E | Samsung SSD 970 EVO Plus | 32 | 19.3 | WSL | |
Go | 70000 | 777698 | 65.9 | 11801 | 3900x | 12P / 0E | Samsung SSD 970 EVO Plus | 32 | 19.3 | WSL | |
Go | 80000 | 888798 | 77.57 | 11458 | 3900x | 12P / 0E | Samsung SSD 970 EVO Plus | 32 | 19.3 | WSL | |
Go | 90000 | 999898 | 88.16 | 11342 | 3900x | 12P / 0E | Samsung SSD 970 EVO Plus | 32 | 19.3 | WSL | |
Go | 100000 | 1110998 | 100.42 | 11064 | 3900x | 12P / 0E | Samsung SSD 970 EVO Plus | 32 | 19.3 | WSL |