mirror of
https://blitiri.com.ar/repos/chasquid
synced 2025-12-18 14:47:03 +00:00
nettrace: Add a new tracing library
This commit introduces a new tracing library, that replaces golang.org/x/net/trace, and supports (amongts other thing) nested traces. This is a minimal change, future patches will make use of the new functionality.
This commit is contained in:
29
internal/nettrace/histogram_test.go
Normal file
29
internal/nettrace/histogram_test.go
Normal file
@@ -0,0 +1,29 @@
|
||||
package nettrace
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestHistogramBasic(t *testing.T) {
|
||||
h := histogram{}
|
||||
h.Add(1, 1*time.Millisecond)
|
||||
|
||||
snap := h.Snapshot()
|
||||
if snap.Count != 1 ||
|
||||
snap.Min != 1*time.Millisecond ||
|
||||
snap.Max != 1*time.Millisecond ||
|
||||
snap.Avg != 1*time.Millisecond {
|
||||
t.Errorf("expected snapshot with only 1 sample, got %v", snap)
|
||||
}
|
||||
}
|
||||
|
||||
func TestHistogramEmpty(t *testing.T) {
|
||||
h := histogram{}
|
||||
snap := h.Snapshot()
|
||||
|
||||
if len(snap.Counts) != nBuckets || snap.Count != 0 ||
|
||||
snap.Avg != 0 || snap.Min != 0 || snap.Max != 0 {
|
||||
t.Errorf("expected zero snapshot, got %v", snap)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user