-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy patht.docx_bench_test.go
68 lines (58 loc) · 1.45 KB
/
t.docx_bench_test.go
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
58
59
60
61
62
63
64
65
66
67
68
package docxplate_test
import (
"log"
"testing"
"github.com/bobiverse/docxplate"
)
func BenchmarkLists100(b *testing.B) {
var user = User{
Name: "Walter",
}
for i := 0; i < 100; i++ {
user.Friends = append(user.Friends, &User{Name: "Bob", Age: 28})
}
tdoc, _ := docxplate.OpenTemplate("test-data/lists.docx")
tdoc.Params(user)
if err := tdoc.ExportDocx("test-data/~test-lists.docx"); err != nil {
log.Fatal(err)
}
}
func BenchmarkLists200(b *testing.B) {
var user = User{
Name: "Walter",
}
for i := 0; i < 200; i++ {
user.Friends = append(user.Friends, &User{Name: "Bob", Age: 28})
}
tdoc, _ := docxplate.OpenTemplate("test-data/lists.docx")
tdoc.Params(user)
if err := tdoc.ExportDocx("test-data/~test-lists.docx"); err != nil {
log.Fatal(err)
}
}
func BenchmarkLists400(b *testing.B) {
var user = User{
Name: "Walter",
}
for i := 0; i < 400; i++ {
user.Friends = append(user.Friends, &User{Name: "Bob", Age: 28})
}
tdoc, _ := docxplate.OpenTemplate("test-data/lists.docx")
tdoc.Params(user)
if err := tdoc.ExportDocx("test-data/~test-lists.docx"); err != nil {
log.Fatal(err)
}
}
func BenchmarkLists1000(b *testing.B) {
var user = User{
Name: "Walter",
}
for i := 0; i < 1000; i++ {
user.Friends = append(user.Friends, &User{Name: "Bob", Age: 28})
}
tdoc, _ := docxplate.OpenTemplate("test-data/lists.docx")
tdoc.Params(user)
if err := tdoc.ExportDocx("test-data/~test-lists.docx"); err != nil {
log.Fatal(err)
}
}