mirror of https://github.com/v2ray/v2ray-core
benchmark task
parent
5c5816072e
commit
61b1013571
|
@ -6,6 +6,7 @@ import (
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"v2ray.com/core/common"
|
||||||
. "v2ray.com/core/common/task"
|
. "v2ray.com/core/common/task"
|
||||||
. "v2ray.com/ext/assert"
|
. "v2ray.com/ext/assert"
|
||||||
)
|
)
|
||||||
|
@ -41,3 +42,32 @@ func TestExecuteParallelContextCancel(t *testing.T) {
|
||||||
|
|
||||||
assert(err.Error(), HasSubstring, "canceled")
|
assert(err.Error(), HasSubstring, "canceled")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func BenchmarkExecuteOne(b *testing.B) {
|
||||||
|
noop := func() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
common.Must(Run(Parallel(noop))())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkExecuteTwo(b *testing.B) {
|
||||||
|
noop := func() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
common.Must(Run(Parallel(noop, noop))())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func BenchmarkExecuteContext(b *testing.B) {
|
||||||
|
noop := func() error {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
background := context.Background()
|
||||||
|
|
||||||
|
for i := 0; i < b.N; i++ {
|
||||||
|
common.Must(Run(WithContext(background), Parallel(noop, noop))())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue