示例#1
0
func benchPhoneMnemonics(b *testing.B, size int) {
	number := epiutil.RandStr(size, "0123456789", rand.NewSource(int64(size)))
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		PhoneMnemonics(number)
	}
}
示例#2
0
func benchCanFormPalindrome(b *testing.B, size int) {
	s := epiutil.RandStr(size, "abcdefghijklmnopqrstuvwxyz", rand.NewSource(int64(size)))
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		CanFormPalindrome(s)
	}
}
示例#3
0
func benchReverseFn(b *testing.B, size int, fn reverseFn) {
	s := epiutil.RandStr(size, "☺ abcdefghijklm nopqrstuvwxyz 世界", rand.NewSource(int64(size)))
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		fn(s)
	}
}
示例#4
0
func benchCountOccurrences(b *testing.B, size int) {
	s := epiutil.RandStr(size, "0123456789abcdefghijklmnopqrstuvwxyz", rand.NewSource(int64(size)))
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		CountOccurrences(s)
	}
}
示例#5
0
func benchReverseWords(b *testing.B, size int) {
	s := epiutil.RandStr(size, "The quick brown fox jumps over the lazy dog", rand.NewSource(int64(size))) // Pangram.
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		ReverseWords(s)
	}
}
示例#6
0
func benchIsLetterSubset(b *testing.B, size int) {
	m := epiutil.RandStr(size, "ab cd ef gh ij kl mn op qr st uv wx yz", rand.NewSource(int64(size)))
	l := m[:size/2]
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		IsLetterSubset(l, m)
	}
}
示例#7
0
func benchIndexFn(b *testing.B, size int, fn indexFn) {
	s := epiutil.RandStr(size, "☺ abcdefghijklmnopqrstuvwxyz 世界", rand.NewSource(time.Now().UnixNano()))
	p := s[size/3 : size*2/3]
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		fn(s, p)
	}
}
示例#8
0
func benchGroupAnagrams(b *testing.B, n, m int) {
	words := make([]string, n)
	for i := 0; i < n; i++ {
		words[i] = epiutil.RandStr(m, "abcdefghijklmnopqrstuvwxyz", rand.NewSource(int64(i)))
	}
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		GroupAnagrams(words)
	}
}
示例#9
0
func benchRLEDecode(b *testing.B, size int) {
	s, ok := RLEEncode(epiutil.RandStr(size, "abcdefghijklmnopqrstuvwxyz", rand.NewSource(int64(size))))
	if !ok {
		b.Error("RLEEncode did not encode string properly")
	}
	b.ResetTimer()
	for i := 0; i < b.N; i++ {
		RLEDecode(s)
	}
}