Skip to content

Commit 4732c09

Browse files
committed
Calculate total execution time for redisgraph profile
1 parent 7c38d91 commit 4732c09

File tree

2 files changed

+17
-3
lines changed

2 files changed

+17
-3
lines changed

redisinsight/ui/src/packages/ri-explain/src/Explain.tsx

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import {
1212
ParseProfile,
1313
ParseProfileCluster,
1414
GetAncestors,
15+
GetTotalExecutionTime,
1516
} from './parser'
1617
import { ExplainNode, ProfileNode } from './Node'
1718

@@ -21,22 +22,30 @@ interface IExplain {
2122
}
2223

2324
function getEdgeSize(c: number) {
24-
return (Math.log(c || 1) / Math.log(3)) + 1
25+
return (Math.log(c || 1) / Math.log(10)) + 1
2526
}
2627

2728
export default function Explain(props: IExplain): JSX.Element {
2829
const command = props.command.split(' ')[0].toLowerCase()
2930

3031
if (command.startsWith('graph')) {
3132
const info = props.data[0].response
32-
3333
const resp = ParseGraphV2(info)
3434

35+
let profilingTime: IProfilingTime = {}
36+
let t = command.endsWith('explain') ? CoreType.Explain : CoreType.Profile
37+
if (t === CoreType.Profile) {
38+
profilingTime = {
39+
'Total Execution Time': GetTotalExecutionTime(resp)
40+
}
41+
}
42+
3543
return (
3644
<ExplainDraw
3745
data={resp}
3846
module={ModuleType.Graph}
39-
type={command.endsWith('explain') ? CoreType.Explain : CoreType.Profile}
47+
type={t}
48+
profilingTime={profilingTime}
4049
/>
4150
)
4251
}

redisinsight/ui/src/packages/ri-explain/src/parser.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,3 +803,8 @@ export function ParseGraphV2(output: string[]) {
803803
entity.children = children
804804
return entity
805805
}
806+
807+
808+
export function GetTotalExecutionTime(g: EntityInfo) {
809+
return parseFloat(g.time || '') + g.children.reduce((a, c) => a + GetTotalExecutionTime(c), 0)
810+
}

0 commit comments

Comments
 (0)