11<template >
22 <div class =" profiler-page-callstack" >
33 <header class =" profiler-page-callstack__header" >
4- <div class =" profiler-page-callstack__header-cpu" >CPU / Memory</div >
5- <div class =" profiler-page-callstack__header-calls" >Calls</div >
4+ <div class =" profiler-page-callstack__header-cpu" >
5+ <SortWrap :sort =" sortCPU" @changeSort =" changeCPUOrder" > CPU </SortWrap >
6+ /
7+ <SortWrap :sort =" sortMemory" @changeSort =" changeMemoryOrder" >
8+ Memory
9+ </SortWrap >
10+ </div >
11+ <div class =" profiler-page-callstack__header-calls" >
12+ <SortWrap :sort =" sortCalls" @changeSort =" changeCallsOrder" >
13+ Calls
14+ </SortWrap >
15+ </div >
616 </header >
717
818 <div class =" profiler-page-callstack__calls" >
2131import { defineComponent , PropType } from " vue" ;
2232import { Profiler } from " ~/config/types" ;
2333import ProfilerPageCallStackRow from " ~/components/ProfilerPageCallStackRow/ProfilerPageCallStackRow.vue" ;
34+ import SortWrap from " ~/components/SortWrap/SortWrap.vue" ;
35+ import { SORT_ORDER } from " ~/config/constants" ;
2436
2537export default defineComponent ({
26- components: { ProfilerPageCallStackRow },
38+ components: {
39+ ProfilerPageCallStackRow ,
40+ SortWrap ,
41+ },
2742 props: {
2843 event: {
2944 type: Object as PropType <Profiler >,
3045 required: true ,
3146 },
3247 },
3348 emits: [" hover" , " hide" ],
49+ data() {
50+ return {
51+ sortCPU: SORT_ORDER .ASC ,
52+ sortMemory: SORT_ORDER .DEFAULT ,
53+ sortCalls: SORT_ORDER .DEFAULT ,
54+ };
55+ },
3456 computed: {
3557 sortedEdges() {
58+ const sortEdgesEntries = ([, a ], [, b ]) => {
59+ if (this .sortCPU === SORT_ORDER .ASC ) {
60+ return b .cost .p_cpu - a .cost .p_cpu ;
61+ }
62+ if (this .sortCPU === SORT_ORDER .DESC ) {
63+ return a .cost .p_cpu - b .cost .p_cpu ;
64+ }
65+ if (this .sortMemory === SORT_ORDER .ASC ) {
66+ return b .cost .p_mu - a .cost .p_mu ;
67+ }
68+ if (this .sortMemory === SORT_ORDER .DESC ) {
69+ return a .cost .p_mu - b .cost .p_mu ;
70+ }
71+ if (this .sortCalls === SORT_ORDER .ASC ) {
72+ return b .cost .ct - a .cost .ct ;
73+ }
74+ if (this .sortCalls === SORT_ORDER .DESC ) {
75+ return a .cost .ct - b .cost .ct ;
76+ }
77+
78+ return 0 ;
79+ };
80+
3681 return Object .entries (this .event .edges )
37- .sort (([, a ], [, b ]) => b . cost . p_cpu - a . cost . p_cpu )
82+ .sort (sortEdgesEntries )
3883 .reduce ((r , [k , v ]) => ({ ... r , [k ]: v }), {});
3984 },
4085 },
86+ methods: {
87+ changeCPUOrder(sortValue : SORT_ORDER ) {
88+ this .sortCPU = sortValue ;
89+ this .sortMemory = SORT_ORDER .DEFAULT ;
90+ this .sortCalls = SORT_ORDER .DEFAULT ;
91+ },
92+ changeMemoryOrder(sortValue : SORT_ORDER ) {
93+ this .sortCPU = SORT_ORDER .DEFAULT ;
94+ this .sortMemory = sortValue ;
95+ this .sortCalls = SORT_ORDER .DEFAULT ;
96+ },
97+ changeCallsOrder(sortValue : SORT_ORDER ) {
98+ this .sortCPU = SORT_ORDER .DEFAULT ;
99+ this .sortMemory = SORT_ORDER .DEFAULT ;
100+ this .sortCalls = sortValue ;
101+ },
102+ },
41103});
42104 </script >
43105
@@ -46,11 +108,11 @@ export default defineComponent({
46108}
47109
48110.profiler-page-callstack__header {
49- @apply flex items-stretch bg-gray-600 text-xs text-white text-center font-bold uppercase py- 2;
111+ @apply flex items-stretch bg-gray-400 dark :bg - gray - 600 text- xs dark : text- white text - gray - 800 text- center font- bold uppercase py- 2;
50112}
51113
52114.profiler-page-callstack__header-cpu {
53- @apply flex-1 text-white ;
115+ @apply flex-1 dark : text- white text - gray - 800 ;
54116}
55117
56118.profiler-page-callstack__header-calls {
0 commit comments