📌  相关文章
📜  goland 打印代码运行所花费的时间 - Go 编程语言 - Go 编程语言代码示例

📅  最后修改于: 2022-03-11 14:45:00.812000             🧑  作者: Mango

代码示例1
package main 

import (
    "time" // Import this to be able to track time
    "fmt" // Import this to print in console
)

//This app will check how long it takes for the computer to print 2000 numbers

func main () {
    start := time.Now()

    for i := 0; i < 2000; i++{
        fmt.Println(i)
    }

    elapsed := time.Since(start) // This will check how long has passed since time.Now() was executed
    fmt.Println(elapsed)
}