-
-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathBuildMetrics.vue
More file actions
83 lines (76 loc) · 2.4 KB
/
Copy pathBuildMetrics.vue
File metadata and controls
83 lines (76 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<script setup lang="ts">
import type { ModuleBuildMetrics } from '~~/shared/types'
import { computed } from 'vue'
const props = defineProps<{
metrics: ModuleBuildMetrics
}>()
const durations = computed(() => {
const data = props.metrics
const _resolveIds = data?.resolve_ids.reduce((t, node) => {
t += node.duration
return t
}, 0) ?? 0
const _loads = data?.loads?.reduce((t, node) => {
t += node.duration
return t
}, 0) ?? 0
const _transforms = data?.transforms.reduce((t, node) => {
t += node.duration
return t
}, 0) ?? 0
const total = _resolveIds + _loads + _transforms
return {
resolveIds: _resolveIds,
loads: _loads,
transforms: _transforms,
total,
}
})
const sourceCodeSize = computed(() => {
const data = props.metrics?.transforms
return data?.[0]?.source_code_size
})
const transformedCodeSize = computed(() => {
const data = props.metrics?.transforms.filter(t => t.transformed_code_size)
return data?.[data.length - 1]?.transformed_code_size
})
</script>
<template>
<div text-xs font-mono flex="~ items-center gap-3" ml2>
<DisplayDuration
:duration="durations.resolveIds" flex="~ gap-1 items-center"
:title="`resolveId hooks cost: ${durations.resolveIds}ms`"
>
<span i-ph-magnifying-glass-duotone inline-block />
</DisplayDuration>
<DisplayDuration
:duration="durations.loads" flex="~ gap-1 items-center"
:title="`load hooks cost: ${durations.loads}ms`"
>
<span i-ph-upload-simple-duotone inline-block />
</DisplayDuration>
<DisplayDuration
:duration="durations.transforms" flex="~ gap-1 items-center"
:title="`transform hooks cost: ${durations.transforms}ms`"
>
<span i-ph-magic-wand-duotone inline-block />
</DisplayDuration>
<span op40>|</span>
<DisplayDuration
:duration="durations.total" flex="~ gap-1 items-center"
:title="`Total build cost: ${durations.total}ms`"
>
<span i-ph-clock-duotone inline-block />
</DisplayDuration>
<template v-if="sourceCodeSize && transformedCodeSize">
<span op40>|</span>
<div flex="~ gap-1 items-center">
<DisplayFileSizeBadge title="Source code size" :bytes="sourceCodeSize" />
<span i-carbon-arrow-right op50 />
<DisplayFileSizeBadge title="Transformed code size" :bytes="transformedCodeSize" />
</div>
</template>
</div>
</template>
<style scoped>
</style>