Last active
August 22, 2021 12:11
-
-
Save andrewchambers/5e50a90b904e8b23d73f613ca82911fe to your computer and use it in GitHub Desktop.
go-collectd-benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func BenchmarkWriteEncryptedPacket(bench *testing.B) { | |
bench.ReportAllocs() | |
out := make([]byte, 65535) | |
ctx := context.Background() | |
b := NewBuffer(0) | |
b.Encrypt("user", "password") | |
vl := &api.ValueList{ | |
Identifier: api.Identifier{ | |
Host: "example.com", | |
Plugin: "golang", | |
Type: "gauge", | |
}, | |
Time: time.Unix(1426076671, 123000000), // Wed Mar 11 13:24:31 CET 2015 | |
Interval: 10 * time.Second, | |
Values: []api.Value{api.Gauge(1)}, | |
} | |
if err := b.Write(ctx, vl); err != nil { | |
bench.Fatal(err) | |
} | |
b.readEncrypted(out) | |
bench.ResetTimer() | |
for n := 0; n < bench.N; n++ { | |
b.Write(ctx, vl) | |
b.readEncrypted(out) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment