Skip to content

Commit 16b24d2

Browse files
relastleHiroki-Konishi
authored andcommitted
Update: main bench
1 parent 43f712a commit 16b24d2

File tree

2 files changed

+15
-10
lines changed

2 files changed

+15
-10
lines changed

main_bench_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@ import (
1111
// BenchmarkLoadLargeRules2 calculates time elapsed to load large rule file
1212
// and fetch them all
1313
func BenchmarkLoadLargeRules2(b *testing.B) {
14-
RULE_COUNT := 10000
14+
const ruleNum int = 10000
15+
const cmdGroupNum int = 1
1516
filePath := "./test_pmy_rules_large.json"
16-
pmy.DumpDummyRulesJSON(filePath, RULE_COUNT)
17+
pmy.DumpDummyRulesJSON(filePath, ruleNum, cmdGroupNum)
1718
b.ResetTimer()
1819
out := pmy.Run(
1920
filePath,

src/rule.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,16 +40,20 @@ func loadAllRules(cfgPath string) (pmyRules, error) {
4040
}
4141

4242
// DumpDummyRulesJSON dumps arbitrary number of rules into given file path
43-
func DumpDummyRulesJSON(resultPath string, n int) error {
43+
func DumpDummyRulesJSON(resultPath string, ruleNum int, cmdGroupNum int) error {
4444
pmyRules := pmyRules{}
45-
for i := 0; i < n; i++ {
46-
cgs := CmdGroups{&CmdGroup{
47-
Tag: fmt.Sprintf("test%v", n),
48-
Stmt: "ls -alh",
49-
After: "awk '{print $1}'",
50-
}}
45+
for i := 0; i < ruleNum; i++ {
46+
cgs := CmdGroups{}
47+
for j := 0; j < cmdGroupNum; j++ {
48+
cg := &CmdGroup{
49+
Tag: fmt.Sprintf("test%v", ruleNum),
50+
Stmt: "find /Users/hkonishi/ -maxdepth 2",
51+
After: "awk '{print $1}'",
52+
}
53+
cgs = append(cgs, cg)
54+
}
5155
rule := &pmyRule{
52-
Name: fmt.Sprintf("test%v", n),
56+
Name: fmt.Sprintf("test%v", ruleNum),
5357
RegexpLeft: ".*test.*",
5458
RegexpRight: "",
5559
CmdGroups: cgs,

0 commit comments

Comments
 (0)