dmitri.shuralyov.com/text/kebabcase

Add benchmark for Parse.

	name     time/op
	Parse-8  629ns ± 3%

The performance of strings.Split on a 1-byte length string is very
good (optional CPU features and assembly are employed), and a naive
custom implementation is significantly slower (1100-2500 ns/op).
dmitshur committed 7 years ago commit bf160e40a7918fbe9dc3cc841a023d87242bd2eb
Showing partial commit. Full Commit
Collapse all
kebabcase_test.go
@@ -32,5 +32,16 @@ func TestParse(t *testing.T) {
		if !reflect.DeepEqual(got, tc.want) {
			t.Errorf("got: %q, want: %q", got, tc.want)
		}
	}
}

func BenchmarkParse(b *testing.B) {
	for i := 0; i < b.N; i++ {
		kebabcase.Parse("book")
		kebabcase.Parse("bookmark")
		kebabcase.Parse("arrow-right")
		kebabcase.Parse("arrow-small-right")
		kebabcase.Parse("device-camera-video-audio")
		kebabcase.Parse("rss")
	}
}