Skip to content

Commit c02531e

Browse files
Add DB and CPU timings (with logo)
1 parent f99d671 commit c02531e

3 files changed

Lines changed: 68 additions & 20 deletions

File tree

‎client/index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ <h2 class="text-2xl font-bold tracking-tight text-gray-900">Everything you need
6969
<div id="__debugbar"></div>
7070
<script type="text/javascript">
7171
window._debugbarConfigOptions = {
72-
mode: "poll",
72+
mode: "ws",
7373
height: 600,
7474
// poll: {
7575
// interval: 1000,

‎client/src/Debugbar.vue‎

Lines changed: 34 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ import {
88
TrashIcon,
99
PauseIcon,
1010
PlayIcon,
11+
CircleStackIcon,
12+
ArrowsUpDownIcon,
13+
CpuChipIcon,
1114
} from "@heroicons/vue/16/solid"
1215
1316
import TabButton from "@/components/TabButton.vue"
@@ -23,6 +26,7 @@ import CachePanel from "@/components/panels/CachePanel.vue"
2326
import RequestPanel from "@/components/panels/RequestPanel.vue"
2427
import JsonPanel from "@/components/panels/JsonPanel.vue"
2528
import RubyLogo from "@/components/ui/RubyLogo.vue"
29+
import Timing from "@/components/ui/Timing.vue"
2630
2731
let requestsStore = useRequestsStore()
2832
let configStore = useConfigStore()
@@ -167,14 +171,17 @@ const setActiveTab = (tab) => {
167171
<div
168172
v-if="state.minimized"
169173
@click="state.minimized = false"
170-
class="z-[9999] fixed left-0 bottom-0 bg-transparent cursor-pointer"
174+
class="z-[9999] text-stone-900 fixed left-0 bottom-0 bg-transparent cursor-pointer"
171175
>
172176
<div class="p-1 pt-1.5">
173177
<ruby-logo />
174178
</div>
175179
</div>
176180

177-
<div v-if="!state.minimized && requestsStore.currentRequest == null" class="z-[9999] fixed left-0 bottom-0 w-full">
181+
<div
182+
v-if="!state.minimized && requestsStore.currentRequest == null"
183+
class="z-[9999] text-stone-900 fixed left-0 bottom-0 w-full"
184+
>
178185
<div class="h-0.5 bg-red-700 cursor-row-resize" />
179186
<div class="flex items-center justify-between bg-stone-100 border-b border-stone-200">
180187
<div class="px-5 py-1.5 italic">No request yet</div>
@@ -186,7 +193,10 @@ const setActiveTab = (tab) => {
186193
</div>
187194
</div>
188195

189-
<div v-if="!state.minimized && requestsStore.currentRequest" class="z-[9999] fixed left-0 bottom-0 w-full">
196+
<div
197+
v-if="!state.minimized && requestsStore.currentRequest"
198+
class="z-[9999] text-stone-900 fixed left-0 bottom-0 w-full"
199+
>
190200
<div id="draggable-bar" @mousedown="state.isResizing = true" class="h-0.5 bg-red-700 cursor-row-resize" />
191201

192202
<div
@@ -224,26 +234,31 @@ const setActiveTab = (tab) => {
224234
</div>
225235

226236
<!-- Right -->
227-
<div class="flex items-center space-x-2.5 pr-1">
237+
<div class="flex items-center space-x-3 pr-1">
238+
<div class="flex space-x-2">
239+
<timing :duration-ms="requestsStore.currentRequest.meta.db_runtime">
240+
<circle-stack-icon class="text-stone-600 size-3" />
241+
</timing>
242+
243+
<timing :duration-ms="requestsStore.currentRequest.meta.cpu_time">
244+
<cpu-chip-icon class="text-stone-600 size-3" />
245+
</timing>
246+
247+
<timing
248+
:duration-ms="requestsStore.currentRequest.meta.duration"
249+
:too-slow-threshold="1000"
250+
:slow-threshold="750"
251+
class="font-bold"
252+
>
253+
<arrows-up-down-icon class="text-stone-800 size-4" />
254+
</timing>
255+
</div>
256+
228257
<div @click="setActiveTab('request')" class="flex space-x-2 cursor-pointer">
229258
<span class="text-sm text-stone-600 font-medium tracking-wide">
230259
{{ routeAlias }}
231260
</span>
232261

233-
<span
234-
class="text-sm font-bold"
235-
v-if="requestsStore.currentRequest.meta.duration < 1000"
236-
:class="{
237-
'text-orange-600': requestsStore.currentRequest.meta.duration >= 800,
238-
}"
239-
>{{ requestsStore.currentRequest.meta.duration.toFixed(1) }}ms</span
240-
>
241-
<span
242-
class="text-sm font-bold text-red-600 bg-red-100 px-1 rounded"
243-
v-if="requestsStore.currentRequest.meta.duration >= 1000"
244-
>{{ (requestsStore.currentRequest.meta.duration / 1000).toFixed(2) }}s</span
245-
>
246-
247262
<span
248263
class="px-1 py-0.5 rounded text-xs"
249264
:class="{
@@ -284,7 +299,7 @@ const setActiveTab = (tab) => {
284299
<play-icon v-if="!state.isPolling" class="size-4" />
285300
</button>
286301
<button @click="clearRequests" title="Clear all requests (frontend and backend)">
287-
<trash-icon class="size-4" />
302+
<trash-icon class="size-3" />
288303
</button>
289304
<button @click="state.minimized = true" title="Hide in the corner">
290305
<arrow-down-left-icon class="size-4" />
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<script setup lang="ts">
2+
import { computed } from "vue"
3+
4+
const props = withDefaults(
5+
defineProps<{
6+
durationMs: number
7+
slowThreshold?: number
8+
tooSlowThreshold?: number
9+
}>(),
10+
{ slowThreshold: 1000, tooSlowThreshold: 1500 }
11+
)
12+
13+
const formattedDuration = computed(() => {
14+
if (props.durationMs >= 1000) {
15+
return (props.durationMs / 1000).toFixed(2) + "s"
16+
}
17+
return props.durationMs.toFixed(1) + "ms"
18+
})
19+
</script>
20+
21+
<template>
22+
<div class="flex items-center">
23+
<slot></slot>
24+
<span
25+
:class="{
26+
'px-1 py-0.5 rounded text-sm': true,
27+
'text-orange-600': durationMs >= props.slowThreshold && durationMs < props.tooSlowThreshold,
28+
'text-red-600 bg-red-100': durationMs >= props.tooSlowThreshold,
29+
}"
30+
v-text="formattedDuration"
31+
></span>
32+
</div>
33+
</template>

0 commit comments

Comments
 (0)