-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathshell_test.go
More file actions
29 lines (25 loc) · 818 Bytes
/
shell_test.go
File metadata and controls
29 lines (25 loc) · 818 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package shell
import (
"github.com/stretchr/testify/assert"
"github.com/xiaomeng79/go-algorithm/algorithms/sort/testdata"
"github.com/xiaomeng79/go-algorithm/algorithms/sort/utils"
"testing"
)
func TestShell(t *testing.T) {
for _, v := range testdata.Values {
assert.Exactly(t, v.Sort, ShellSort(v.Nosort), "no eq")
}
}
func benchmarkShellSort(n int, b *testing.B) {
b.StopTimer()
list := utils.GetArrayOfSize(n)
b.ReportAllocs()
b.StartTimer()
for i := 0; i < b.N; i++ {
ShellSort(list)
}
}
func BenchmarkShellSort100(b *testing.B) { benchmarkShellSort(100, b) }
func BenchmarkShellSort1000(b *testing.B) { benchmarkShellSort(1000, b) }
func BenchmarkShellSort10000(b *testing.B) { benchmarkShellSort(10000, b) }
func BenchmarkShellSort100000(b *testing.B) { benchmarkShellSort(100000, b) }