测试go的性能需要的耗时

package main

import (
    "fmt"
    "net/http"
    "time"
)

func main() {
    start := time.Now()
    for i := 0; i < 100; i++ {
        resp, err := http.Get("https://index.golang.org")
        if err != nil {
            continue
        }
        resp.Body.Close()
    }
    fmt.Printf("耗时: %v\n", time.Since(start))
}

 

posted @ 2026-11-23 13:37  技术颜良  阅读(6)  评论(0)    收藏  举报