Skip to content

Instantly share code, notes, and snippets.

@tikazyq
Last active June 3, 2021 16:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tikazyq/e596f9c7b214b4f0b368570ed4ee21a0 to your computer and use it in GitHub Desktop.
Save tikazyq/e596f9c7b214b4f0b368570ed4ee21a0 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"time"
)
func main() {
st := time.Now()
n := 100000000
for i := 0; i < n; i++ {
}
fmt.Println(fmt.Sprintf("%f seconds", float32(time.Now().Sub(st).Microseconds()) / 1000000))
// 0.058280 seconds
}
from datetime import datetime
st = datetime.now()
n = 100000000
_ = [i for i in range(n)]
ed = datetime.now()
d = ed - st
print('%f seconds' % (d.seconds + d.microseconds / 1e6))
# 3.965864 seconds
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment