We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
func BenchmarkLoadRule(b *testing.B) { ruleNames := []string{} conditions := []string{} actions := []string{} for i := 0; i < 10000; i++ { ruleNames = append(ruleNames, fmt.Sprintf("rule%d", i)) conditions = append(conditions, fmt.Sprintf(`{"OpLogic":"&&","Conditions":[{"Operator":"==","Lhs":{"VarExpr":"fromId"},"Rhs":{"Const":{"StrConst":"HuangShan"}}},{"Operator":"LIST_IN","Lhs":{"VarExpr":"customerGroupId"},"Rhs":{"ConstList":[{"StrConst":"10549"},{"StrConst":"%d"}]}}]}`, i+1)) actions = append(actions, fmt.Sprintf(`{"ActionName":"Greeting","ParamMap":{"SupplyType":{"Const":{"StrConst":"黄山%d"}}}}`, i+1)) } for i := 0; i < b.N; i++ { for i := 0; i < 10000; i++ { arishem.NewPriorityRule(ruleNames[i], i+1, conditions[i], actions[i]) } } }
go test -benchmem -run=^$ -bench ^BenchmarkNewPriorityRule$ antrl/test
Running tool: /usr/local/go/bin/go test -benchmem -run=^$ -bench ^BenchmarkLoadRule$ antrl/test goos: linux goarch: amd64 pkg: antrl/test cpu: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz BenchmarkLoadRule-8 1 13479184237 ns/op 7858983688 B/op 153870732 allocs/op PASS ok antrl/test 13.492s
func BenchmarkExecuteRule(b *testing.B) { ruleNames := []string{} conditions := []string{} actions := []string{} for i := 0; i < 10000; i++ { ruleNames = append(ruleNames, fmt.Sprintf("rule%d", i)) conditions = append(conditions, fmt.Sprintf(`{"OpLogic":"&&","Conditions":[{"Operator":"==","Lhs":{"VarExpr":"fromId"},"Rhs":{"Const":{"StrConst":"HuangShan"}}},{"Operator":"LIST_IN","Lhs":{"VarExpr":"customerGroupId"},"Rhs":{"ConstList":[{"StrConst":"10549"},{"StrConst":"%d"}]}}]}`, i+1)) actions = append(actions, fmt.Sprintf(`{"ActionName":"Greeting","ParamMap":{"SupplyType":{"Const":{"StrConst":"黄山%d"}}}}`, i+1)) } count := 5000 rules := make([]arishem.RuleTarget, count) for i := 0; i < count; i++ { rule, _ := arishem.NewPriorityRule(ruleNames[i], i+1, conditions[i], actions[i]) rules[i] = rule } for i := 0; i < b.N; i++ { dc, err := arishem.DataContext(context.Background(), ` { "fromId": "HuangShan", "customerGroupId": "10549", "provinceId": "157", "supplyType": "", "item_list": [ { "name": "name@1", "price": 1 }, { "name": "name@2", "price": 102.13 } ] } `) if err != nil { panic(err) } arishem.ExecuteRules(rules, dc) } }
go test -benchmem -run=^$ -bench ^BenchmarkExecuteRule$ antrl/test
Running tool: /usr/local/go/bin/go test -benchmem -run=^$ -bench ^BenchmarkExecuteRule$ antrl/test goos: linux goarch: amd64 pkg: antrl/test cpu: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz BenchmarkExecuteRule-8 1 7063361703 ns/op 3931025664 B/op 76959585 allocs/op PASS ok antrl/test 7.095s
请问为什么当规则条数非常大时,内存占用如此高,有什么手段可以优化吗,谢谢
The text was updated successfully, but these errors were encountered:
No branches or pull requests
加载万条规则
go test -benchmem -run=^$ -bench ^BenchmarkNewPriorityRule$ antrl/test
加载五千条规则后执行匹配
go test -benchmem -run=^$ -bench ^BenchmarkExecuteRule$ antrl/test
请问为什么当规则条数非常大时,内存占用如此高,有什么手段可以优化吗,谢谢
The text was updated successfully, but these errors were encountered: