blob: cf61acb4aba3975e3ea20462eb1de757a34b23f2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
package gtscontext_test
import (
"context"
"net/url"
"testing"
"code.superseriousbusiness.org/gotosocial/internal/gtscontext"
"code.superseriousbusiness.org/gotosocial/internal/gtsmodel"
)
func BenchmarkContexts(b *testing.B) {
var receiving *gtsmodel.Account
var requesting *gtsmodel.Account
var otherIRIs []*url.URL
b.RunParallel(func(pb *testing.PB) {
for pb.Next() {
ctx := context.Background()
ctx = gtscontext.SetBarebones(ctx)
ctx = gtscontext.SetFastFail(ctx)
ctx = gtscontext.SetDryRun(ctx)
ctx = gtscontext.SetReceivingAccount(ctx, receiving)
ctx = gtscontext.SetRequestingAccount(ctx, requesting)
ctx = gtscontext.SetOtherIRIs(ctx, otherIRIs)
if !gtscontext.Barebones(ctx) {
println("oh no!")
}
if !gtscontext.IsFastfail(ctx) {
println("oh no!")
}
if !gtscontext.DryRun(ctx) {
println("oh no!")
}
if gtscontext.ReceivingAccount(ctx) != nil {
println("oh no!")
}
if gtscontext.RequestingAccount(ctx) != nil {
println("oh no!")
}
if len(gtscontext.OtherIRIs(ctx)) > 0 {
println("oh no!")
}
}
})
}
|