Exemplo n.º 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)
	}
}
Exemplo n.º 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)
	}
}
Exemplo n.º 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)
	}
}
Exemplo n.º 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)
	}
}
Exemplo n.º 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)
	}
}
Exemplo n.º 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)
	}
}
Exemplo n.º 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)
	}
}
Exemplo n.º 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)
	}
}
Exemplo n.º 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)
	}
}