-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathdialog_test.go
More file actions
57 lines (48 loc) · 1.15 KB
/
dialog_test.go
File metadata and controls
57 lines (48 loc) · 1.15 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
package main
import (
"math/rand"
"testing"
)
const letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
func RandomString(n int) string {
b := make([]byte, n)
for i := range b {
b[i] = letters[rand.Intn(len(letters))]
}
return string(b)
}
func RandomStringArray(count, length int) []string {
arr := make([]string, count)
for i := range count {
arr[i] = RandomString(length)
}
return arr
}
func NewComboBoxItems_range(names []string) []*ComboBoxUintStruct {
items := make([]*ComboBoxUintStruct, len(names))
for i, n := range names {
items[i] = &ComboBoxUintStruct{Enums: uint32(i), Name: n}
}
return items
}
func NewComboBoxItems_forindex(names []string) []*ComboBoxUintStruct {
out := make([]*ComboBoxUintStruct, 0, len(names))
for i := uint32(0); i < uint32(len(names)); i++ {
out = append(out, &ComboBoxUintStruct{
Enums: i,
Name: names[i],
})
}
return out
}
var data []string = RandomStringArray(10000, 16)
func Benchmark_NewComboBoxItems1(b *testing.B) {
for b.Loop() {
NewComboBoxItems_range(data)
}
}
func Benchmark_NewComboBoxItems2(b *testing.B) {
for b.Loop() {
NewComboBoxItems_forindex(data)
}
}