File tree Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Expand file tree Collapse file tree 2 files changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -250,8 +250,8 @@ func (s *Scanner) Scan(buf []byte) (*ScanResults, error) {
250
250
type ProfilingInfo struct {
251
251
Namespace string
252
252
Rule string
253
- PatternMatchingTime float64
254
- ConditionExecTime float64
253
+ PatternMatchingTime time. Duration
254
+ ConditionExecTime time. Duration
255
255
}
256
256
257
257
// This is the callback called by yrx_rule_iter_patterns.
@@ -261,7 +261,7 @@ func mostExpensiveRulesCallback(
261
261
namespace * C.char ,
262
262
rule * C.char ,
263
263
patternMatchingTime C.double ,
264
- condExecTime C.double ,
264
+ conditionExecTime C.double ,
265
265
handle C.uintptr_t ) {
266
266
h := cgo .Handle (handle )
267
267
profilingInfo , ok := h .Value ().(* []ProfilingInfo )
@@ -271,8 +271,8 @@ func mostExpensiveRulesCallback(
271
271
* profilingInfo = append (* profilingInfo , ProfilingInfo {
272
272
Namespace : C .GoString (namespace ),
273
273
Rule : C .GoString (rule ),
274
- PatternMatchingTime : float64 (patternMatchingTime ),
275
- ConditionExecTime : float64 (condExecTime ),
274
+ PatternMatchingTime : time . Duration ( float64 (patternMatchingTime ) * float64 ( time . Second ) ),
275
+ ConditionExecTime : time . Duration ( float64 (conditionExecTime ) * float64 ( time . Second ) ),
276
276
})
277
277
}
278
278
Original file line number Diff line number Diff line change @@ -99,8 +99,8 @@ func TestScannerMostExpensiveRules(t *testing.T) {
99
99
profilingInfo := s .MostExpensiveRules (1 )
100
100
assert .Equal (t , "t" , profilingInfo [0 ].Rule )
101
101
assert .Equal (t , "default" , profilingInfo [0 ].Namespace )
102
- assert .Greater (t , profilingInfo [0 ].PatternMatchingTime , float64 (0 ))
103
- assert .Greater (t , profilingInfo [0 ].ConditionExecTime , float64 (0 ))
102
+ assert .Greater (t , profilingInfo [0 ].PatternMatchingTime , time . Duration (0 ))
103
+ assert .Greater (t , profilingInfo [0 ].ConditionExecTime , time . Duration (0 ))
104
104
}
105
105
106
106
func TestScannerMetadata (t * testing.T ) {
You can’t perform that action at this time.
0 commit comments