1 package main 2 3 4 import ( 5 "fmt" 6 "time" 7 ) 8 9 func test() { 10 time.Sleep(time.Millisecond*1000) 11 } 12 13 func main() { 14 now := time.Now() 15 fmt.Println(now.Format("2006/1/02 15:04:05")) 16 17 start := time.Now().UnixNano() 18 test() 19 end := time.Now().UnixNano() 20 21 fmt.Printf("cost time:%d us ", (end -start)/1000) 22 }