console.time("counter");
for (let i = 0; i < 1000000000; i++) {}
console.timeEnd("counter");
counter: 933.401ms
import time
start = time.time()
for i in range(1000000000):
pass
end = time.time()
print(f"Time taken: {end - start} seconds")
Time taken: 26.445303201675415 seconds
package main
import (
"fmt"
"time"
)
func main() {
start := time.Now()
for i := 0; i < 1000000000; i++ {}
fmt.Printf("Time taken: %v seconds\n", time.Since(start).Seconds())
}
Time taken: 0.356702567 seconds
use std::time::Instant;
fn main() {
let start = Instant::now();
for _i in 0..1000000000 {}
println!("Time taken: {:.2} seconds", start.elapsed().as_secs_f64());
}
Time taken: 6.72 seconds