File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed
Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -11,9 +11,10 @@ import (
1111// BenchmarkLoadLargeRules2 calculates time elapsed to load large rule file
1212// and fetch them all
1313func 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 ,
Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments