diff options
author | David Fifield <david@bamsoftware.com> | 2022-09-22 17:09:07 -0600 |
---|---|---|
committer | David Fifield <david@bamsoftware.com> | 2022-11-16 13:48:34 -0700 |
commit | e851861e686520435e456b7ee39ef19097daa60b (patch) | |
tree | 028ee9aef379c8947fdd5f47a97526225170211b | |
parent | a579c969e62a4727b4173b31ed54d338dbe1a4db (diff) | |
download | snowflake-e851861e686520435e456b7ee39ef19097daa60b.tar.gz snowflake-e851861e686520435e456b7ee39ef19097daa60b.zip |
Benchmark for encapsulation.ReadData.
-rw-r--r-- | common/encapsulation/encapsulation_test.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/common/encapsulation/encapsulation_test.go b/common/encapsulation/encapsulation_test.go index 333abb4..27631d0 100644 --- a/common/encapsulation/encapsulation_test.go +++ b/common/encapsulation/encapsulation_test.go @@ -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) + } + } +} |