-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
81 lines (68 loc) · 2.68 KB
/
main.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
79
80
81
package main
import (
"flag"
"os"
"time"
"github.com/RedisLabs/redisearch-go/redisearch"
"github.com/RedisLabs/rsbench/indexer"
"github.com/RedisLabs/rsbench/parser"
)
func main() {
reader := flag.String("reader", "", "Reader to use (if set) [wiki_abs|wiki_full|reddit|twitter]")
path := flag.String("path", "./", "folder/file path")
cons := flag.Int("conns", 100, "Concurrent connections to redis")
files := flag.Int("rnum", 10, "Number of concurrent file readers")
hosts := flag.String("hosts", "localhost:6379", "Redis host(s), comma separated list of ip:port pairs. Use a single value for non cluster version")
index := flag.String("index", "idx", "Index name")
query := flag.String("query", "", "Query to benchmark (if set)")
duration := flag.Int("duration", 5, "Duration to run the query benchmark for")
csv := flag.Bool("csv", false, "If set, we dump the output report as CSV")
chunk := flag.Int("chunk", 1, "Indexing chunk size")
flag.Parse()
if *reader == "" && *query == "" {
panic("Must have query or reader!")
}
if *reader != "" {
var sp indexer.SchemaProvider
var rd indexer.DocumentParser
switch *reader {
case "wiki_abs":
rd = indexer.NewFolderReader(*path, "*.xml", *files, indexer.DocumentReaderOpenerFunc(parser.WikiAbstractReaderOpen))
sp = indexer.SchemaProviderFunc(parser.WikipediaSchema)
case "wiki_full":
rd = indexer.NewFolderReader(*path, "*.bz2", *files, indexer.DocumentReaderOpenerFunc(parser.WikiArticleReaderOpen))
sp = indexer.SchemaProviderFunc(parser.WikipediaSchema)
case "reddit":
rd = indexer.NewFolderReader(*path, "*.bz2", *files, indexer.DocumentReaderOpenerFunc(parser.RedditReaderOpen))
sp = indexer.SchemaProviderFunc(parser.RedditSchema)
case "twitter":
rd = indexer.NewFolderReader(*path, "*.bz2", *files, indexer.DocumentReaderOpenerFunc(parser.TwitterReaderOpen))
sp = indexer.SchemaProviderFunc(parser.TwitterSchema)
case "stack":
rd = indexer.NewSingleFileReader(*path, indexer.DocumentReaderOpenerFunc(parser.StackExchangeReaderOpen))
sp = indexer.SchemaProviderFunc(parser.StackSchema)
default:
panic("Inavlid reader: " + *reader)
}
ch := make(chan redisearch.Document, *cons**chunk)
if err := rd.Start(ch); err != nil {
panic(err)
}
idx := indexer.New(*index, *hosts, *cons, ch, nil, sp, *chunk)
idx.Start()
if idx.GetNumIndexed() == 0 {
panic("No documents indexed!")
}
}
if *query != "" {
client := redisearch.NewClient(*hosts, *index)
b := NewQueryBenchmark(client, *query, *cons, time.Second*time.Duration(*duration))
//fmt.Printf("Starting benchmark for %v\n", time.Until(b.endTime))
b.Run()
if *csv {
b.DumpCSV(os.Stdout)
} else {
b.DumpJson(os.Stdout)
}
}
}