Skip to content

Commit

Permalink
Fix Gitpod casing in proc tests
Browse files Browse the repository at this point in the history
  • Loading branch information
filiptronicek authored and roboquat committed Dec 28, 2021
1 parent b53c34d commit 4e2de28
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion components/ee/agent-smith/pkg/detector/proc.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (p realProcfs) Environ(pid int) ([]string, error) {
}

func parseGitpodEnviron(r io.Reader) ([]string, error) {
// Note: this function is benchmarked in BenchmarkParseGitPodEnviron.
// Note: this function is benchmarked in BenchmarkParseGitpodEnviron.
// At the time of this wriging it consumed 3+N allocs where N is the number of
// env vars starting with GITPOD_.
//
Expand Down
32 changes: 16 additions & 16 deletions components/ee/agent-smith/pkg/detector/proc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,36 +345,36 @@ func TestParseGitpodEnviron(t *testing.T) {
}
}

func benchmarkParseGitPodEnviron(content string, b *testing.B) {
func benchmarkParseGitpodEnviron(content string, b *testing.B) {
b.ReportAllocs()
b.ResetTimer()
for n := 0; n < b.N; n++ {
parseGitpodEnviron(bytes.NewReader([]byte(content)))
}
}

func BenchmarkParseGitPodEnvironP0(b *testing.B) { benchmarkParseGitPodEnviron("", b) }
func BenchmarkParseGitPodEnvironP1(b *testing.B) {
benchmarkParseGitPodEnviron("GITPOD_INSTANCE_ID=foobar\000", b)
func BenchmarkParseGitpodEnvironP0(b *testing.B) { benchmarkParseGitpodEnviron("", b) }
func BenchmarkParseGitpodEnvironP1(b *testing.B) {
benchmarkParseGitpodEnviron("GITPOD_INSTANCE_ID=foobar\000", b)
}
func BenchmarkParseGitPodEnvironP2(b *testing.B) {
benchmarkParseGitPodEnviron("GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000", b)
func BenchmarkParseGitpodEnvironP2(b *testing.B) {
benchmarkParseGitpodEnviron("GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000", b)
}
func BenchmarkParseGitPodEnvironP4(b *testing.B) {
benchmarkParseGitPodEnviron("GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000", b)
benchmarkParseGitpodEnviron("GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000", b)
}
func BenchmarkParseGitPodEnvironP8(b *testing.B) {
benchmarkParseGitPodEnviron("GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000", b)
func BenchmarkParseGitpodEnvironP8(b *testing.B) {
benchmarkParseGitpodEnviron("GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000GITPOD_INSTANCE_ID=foobar\000", b)
}
func BenchmarkParseGitPodEnvironN1(b *testing.B) { benchmarkParseGitPodEnviron("NOT_ME\000", b) }
func BenchmarkParseGitPodEnvironN2(b *testing.B) {
benchmarkParseGitPodEnviron("NOT_ME\000NOT_ME\000", b)
func BenchmarkParseGitpodEnvironN1(b *testing.B) { benchmarkParseGitpodEnviron("NOT_ME\000", b) }
func BenchmarkParseGitpodEnvironN2(b *testing.B) {
benchmarkParseGitpodEnviron("NOT_ME\000NOT_ME\000", b)
}
func BenchmarkParseGitPodEnvironN4(b *testing.B) {
benchmarkParseGitPodEnviron("NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000", b)
func BenchmarkParseGitpodEnvironN4(b *testing.B) {
benchmarkParseGitpodEnviron("NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000", b)
}
func BenchmarkParseGitPodEnvironN8(b *testing.B) {
benchmarkParseGitPodEnviron("NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000", b)
func BenchmarkParseGitpodEnvironN8(b *testing.B) {
benchmarkParseGitpodEnviron("NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000NOT_ME\000", b)
}

func TestParseStat(t *testing.T) {
Expand Down

0 comments on commit 4e2de28

Please sign in to comment.