<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] ## 語法 ### Func 基本都不常用 ``` func AllocsPerRun(runs int, f func()) (avg float64) func CoverMode() string func Coverage() float64 func Init() func Main(matchString func(pat, str string) (bool, error), tests []InternalTest, ...) func RegisterCover(c Cover) func RunBenchmarks(matchString func(pat, str string) (bool, error), ...) func RunExamples(matchString func(pat, str string) (bool, error), examples []InternalExample) (ok bool) func RunTests(matchString func(pat, str string) (bool, error), tests []InternalTest) (ok bool) func Short() bool func Verbose() bool ``` ### Type ``` type B func (c *B) Cleanup(f func()) //在第一次調用后,和執行完后執行 func (c *B) Error(args ...interface{}) func (c *B) Errorf(format string, args ...interface{}) func (c *B) Fail() func (c *B) FailNow() // 停止并標記為失敗 func (c *B) Failed() bool // 是否失敗 func (c *B) Fatal(args ...interface{}) func (c *B) Fatalf(format string, args ...interface{}) func (c *B) Log(args ...interface{}) func (c *B) Logf(format string, args ...interface{}) func (c *B) Helper() func (c *B) Name() string // 測試函數名 // 打開當前基準測試的內存統計功能, // 與使用 -test.benchmem 設置類似,但 ReportAllocs 只影響那些調用了該函數的基準測試 func (b *B) ReportAllocs() func (b *B) ReportMetric(n float64, unit string) func (b *B) Run(name string, f func(b *B)) bool // 運行子程序 // 以并行的方式執行給定的基準測試。 RunParallel 會創建出多個 goroutine // 其中 goroutine 數量的默認值為 GOMAXPROCS func (b *B) RunParallel(body func(*PB)) // 將 RunParallel 使用的 goroutine 數量設置為 p*GOMAXPROCS func (b *B) SetParallelism(p int) // 單個操作中處理的字節數, 基準測試將會報告 ns/op 以及 MB/s func (b *B) SetBytes(n int64) // 跳過測試,并調用日志 func (c *B) Skip(args ...interface{}) func (c *B) SkipNow() func (c *B) Skipf(format string, args ...interface{}) func (c *B) Skipped() bool // 是否跳過 // StartTimer 和 StopTimer 控制時間 func (b *B) StartTimer() func (b *B) StopTimer() func (b *B) ResetTimer() // 清除 ns/op 數 type PB func (pb *PB) Next() bool type T func (c *T) Cleanup(f func()) func (t *T) Deadline() (deadline time.Time, ok bool) func (c *T) Error(args ...interface{}) func (c *T) Errorf(format string, args ...interface{}) func (c *T) Log(args ...interface{}) func (c *T) Logf(format string, args ...interface{}) func (c *T) Fatal(args ...interface{}) func (c *T) Fatalf(format string, args ...interface{}) func (c *T) Fail() func (c *T) FailNow() func (c *T) Failed() bool func (c *T) Helper() func (c *T) Name() string func (t *T) Parallel() // 并行測試 func (t *T) Run(name string, f func(t *T)) bool func (c *T) Skip(args ...interface{}) func (c *T) SkipNow() func (c *T) Skipf(format string, args ...interface{}) func (c *T) Skipped() bool ``` ## 實例 ### RunParallel 并行測試 ``` func BenchmarkHello(b *testing.B) { templ := template.Must(template.New("test").Parse("Hello, {{.}}!")) // RunParallel will create GOMAXPROCS goroutines // and distribute work among them. b.RunParallel(func(pb *testing.PB) { // Each goroutine has its own bytes.Buffer. var buf bytes.Buffer for pb.Next() { // The loop body is executed b.N times total across all goroutines. buf.Reset() templ.Execute(&buf, "World") } }) } ``` ### SetBytes 設置n=1 為一次操作, ``` func Benchmark_Api(b *testing.B) { b.SetBytes(1) for i := 0; i < b.N; i++ { Hello() } } // output: // Benchmark_Api-4 1000000000 0.341 ns/op 2932.28 MB/s ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看