mirror of
https://gitlab.torproject.org/tpo/anti-censorship/pluggable-transports/snowflake.git
synced 2025-10-13 20:11:19 -04:00
Benchmark for encapsulation.ReadData.
This commit is contained in:
parent
a579c969e6
commit
e851861e68
1 changed files with 20 additions and 0 deletions
|
@ -328,3 +328,23 @@ func TestMaxDataForSize(t *testing.T) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Benchmark the ReadData function when reading from a stream of data packets of
|
||||
// different sizes.
|
||||
func BenchmarkReadData(b *testing.B) {
|
||||
pr, pw := io.Pipe()
|
||||
go func() {
|
||||
for {
|
||||
for length := 0; length < 128; length++ {
|
||||
WriteData(pw, paddingBuffer[:length])
|
||||
}
|
||||
}
|
||||
}()
|
||||
|
||||
for i := 0; i < b.N; i++ {
|
||||
_, err := ReadData(pr)
|
||||
if err != nil {
|
||||
b.Fatal(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue