/
githubmirror
/
GoFrame
Обзор
Документация
Войти
/
githubmirror
/
GoFrame
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
os/grpool/grpool_z_bench_test.go
52 строки
909 B
John Guo
unit testing files renaming
17 ноя 2021, 18:20
17 ноя 2021, 18:20
57ccc13
Код
Авторство
О чём код?
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. // // This Source Code Form is subject to the terms of the MIT License. // If a copy of the MIT was not distributed with this file, // You can obtain one at https://github.com/gogf/gf. // go test *.go -bench=".*" package grpool_test import ( "context" "testing" "github.com/gogf/gf/v2/os/grpool" ) var ( ctx = context.TODO() n = 500000 ) func increment(ctx context.Context) { for i := 0; i < 1000000; i++ { } } func BenchmarkGrpool_1(b *testing.B) { for i := 0; i < b.N; i++ { grpool.Add(ctx, increment) } } func BenchmarkGoroutine_1(b *testing.B) { for i := 0; i < b.N; i++ { go increment(ctx) } } func BenchmarkGrpool2(b *testing.B) { b.N = n for i := 0; i < b.N; i++ { grpool.Add(ctx, increment) } } func BenchmarkGoroutine2(b *testing.B) { b.N = n for i := 0; i < b.N; i++ { go increment(ctx) } }