-
Notifications
You must be signed in to change notification settings - Fork 20
/
tldr_benchmark_test.go
78 lines (62 loc) · 1.54 KB
/
tldr_benchmark_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
69
70
71
72
73
74
75
76
77
78
package tldr_test
import (
"github.com/didasy/tldr"
"io/ioutil"
"testing"
)
const (
SAMPLE_FILE_PATH = "./sample.txt"
NUM_SENTENCES = 3
)
var (
benchSummarizer *tldr.Bag
benchText string
resultText []string
)
func init() {
raw, err := ioutil.ReadFile(SAMPLE_FILE_PATH)
if err != nil {
panic(err)
}
benchText = string(raw)
}
func BenchmarkSummarizeCentralityHamming(b *testing.B) {
var rtxt []string
for n := 0; n < b.N; n++ {
benchSummarizer = tldr.New()
benchSummarizer.Algorithm = "centrality"
benchSummarizer.Weighing = "hamming"
rtxt, _ = benchSummarizer.Summarize(benchText, NUM_SENTENCES)
}
resultText = rtxt
}
func BenchmarkSummarizeCentralityJaccard(b *testing.B) {
var rtxt []string
for n := 0; n < b.N; n++ {
benchSummarizer = tldr.New()
benchSummarizer.Algorithm = "centrality"
benchSummarizer.Weighing = "jaccard"
rtxt, _ = benchSummarizer.Summarize(benchText, NUM_SENTENCES)
}
resultText = rtxt
}
func BenchmarkSummarizePagerankHamming(b *testing.B) {
var rtxt []string
for n := 0; n < b.N; n++ {
benchSummarizer = tldr.New()
benchSummarizer.Algorithm = "pagerank"
benchSummarizer.Weighing = "hamming"
rtxt, _ = benchSummarizer.Summarize(benchText, NUM_SENTENCES)
}
resultText = rtxt
}
func BenchmarkSummarizePagerankJaccard(b *testing.B) {
var rtxt []string
for n := 0; n < b.N; n++ {
benchSummarizer = tldr.New()
benchSummarizer.Algorithm = "pagerank"
benchSummarizer.Weighing = "jaccard"
rtxt, _ = benchSummarizer.Summarize(benchText, NUM_SENTENCES)
}
resultText = rtxt
}