-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,6 +26,7 @@ TEST = test/fedora-image/sshproxy_test.go | |
EXE = $(addprefix bin/, sshproxy sshproxy-dumpd sshproxy-replay sshproxyctl) | ||
MANDOC = doc/sshproxy.yaml.5 doc/sshproxy.8 doc/sshproxy-dumpd.8 doc/sshproxy-replay.8 doc/sshproxyctl.8 | ||
PACKAGE = sshproxy_$(SSHPROXY_VERSION)_$(shell uname -s)_$(shell uname -p) | ||
COMMIT = $(shell git describe --dirty) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
cyrilst
Author
Contributor
|
||
|
||
all: exe doc | ||
|
||
|
@@ -93,7 +94,11 @@ check: | |
test: | ||
cd test && bash ./run.sh | ||
|
||
benchmark: | ||
mkdir -p $(GOPATH)/benchmarks/$(PACKAGE) | ||
$(GO) test -failfast -race -count=6 -bench=. -run=^# -benchmem ./... | tee $(GOPATH)/benchmarks/$(PACKAGE)/$(COMMIT) | ||
|
||
clean: | ||
rm -f $(EXE) $(MANDOC) doc/*.xml sshproxy_*.tar.gz | ||
|
||
.PHONY: all exe doc install install-doc-man install-binaries package fmt get-deps check test clean | ||
.PHONY: all exe doc install install-doc-man install-binaries package fmt get-deps check test benchmark clean |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,13 @@ func TestCalcSessionID(t *testing.T) { | |
} | ||
} | ||
|
||
func BenchmarkCalcSessionID(b *testing.B) { | ||
d := time.Unix(1136239445, 0) | ||
for i := 0; i < b.N; i++ { | ||
CalcSessionID("arno", d, "127.0.0.1:22") | ||
This comment has been minimized.
Sorry, something went wrong.
od-cea
Member
|
||
} | ||
} | ||
|
||
var splithostportTests = []struct { | ||
hostport, host, port string | ||
}{ | ||
|
@@ -67,6 +74,16 @@ func TestInvalidSplitHostPort(t *testing.T) { | |
} | ||
} | ||
|
||
func BenchmarkSplitHostPort(b *testing.B) { | ||
for _, tt := range splithostportTests { | ||
b.Run(tt.hostport, func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
SplitHostPort(tt.hostport) | ||
} | ||
}) | ||
} | ||
} | ||
|
||
func mockNetLookupHost(host string) ([]string, error) { | ||
if host == "err" { | ||
return nil, errors.New("LookupHost error") | ||
|
@@ -190,3 +207,14 @@ func TestInvalidMatchSource(t *testing.T) { | |
} | ||
} | ||
} | ||
|
||
func BenchmarkMatchSource(b *testing.B) { | ||
netLookupHost = mockNetLookupHost | ||
for _, tt := range matchSourceTests { | ||
b.Run(tt.source + "_" + tt.sshdHostport, func(b *testing.B) { | ||
for i := 0; i < b.N; i++ { | ||
MatchSource(tt.source, tt.sshdHostport) | ||
} | ||
}) | ||
} | ||
} |
Why using
--dirty
instead of--tags --long
?