A quick comparison of execution speed between Go and Python using simple benchmark logic.
Both programs calculate the sum of all integers from 0 to 100000.
start := time.Now()
sum := 0
for x := 0; x <= 100000; x++ {
sum += x
}
fmt.Printf("Time: %v\n", time.Since(start))start = time.perf_counter()
total = sum(range(100001))
print(f"Time: {time.perf_counter() - start:.6f}s")| Language | Time Taken |
|---|---|
| Go | 0.000508 s |
| Python | 0.010699 s |
⚙️ Go ran ~21× faster than Python for this simple loop.
Author: Mayukh Sen