shadadaab commited on
Commit
1a339fa
·
verified ·
1 Parent(s): d05b637

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +6 -4
  2. index.html +357 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Latency Chart
3
- emoji: 💻
4
- colorFrom: gray
5
  colorTo: gray
6
  sdk: static
7
  pinned: false
 
 
8
  ---
9
 
10
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: latency-chart
3
+ emoji: 🐳
4
+ colorFrom: yellow
5
  colorTo: gray
6
  sdk: static
7
  pinned: false
8
+ tags:
9
+ - deepsite
10
  ---
11
 
12
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
index.html CHANGED
@@ -1,19 +1,357 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Latency Monitoring Candlestick Chart</title>
7
+ <script src="https://cdn.tailwindcss.com"></script>
8
+ <script src="https://unpkg.com/lightweight-charts@3.8.0/dist/lightweight-charts.standalone.production.js"></script>
9
+ <style>
10
+ .chart-container {
11
+ position: relative;
12
+ width: 100%;
13
+ height: 500px;
14
+ }
15
+ .tooltip {
16
+ position: absolute;
17
+ z-index: 1000;
18
+ pointer-events: none;
19
+ background: rgba(30, 41, 59, 0.9);
20
+ border: 1px solid rgba(255, 165, 0, 0.5);
21
+ border-radius: 4px;
22
+ padding: 8px;
23
+ font-size: 12px;
24
+ color: white;
25
+ opacity: 0;
26
+ transition: opacity 0.2s;
27
+ }
28
+ .crosshair-line {
29
+ position: absolute;
30
+ width: 1px;
31
+ background-color: rgba(255, 165, 0, 0.7);
32
+ z-index: 10;
33
+ pointer-events: none;
34
+ }
35
+ .volume-chart {
36
+ height: 120px;
37
+ }
38
+ </style>
39
+ </head>
40
+ <body class="bg-slate-900 text-slate-100">
41
+ <div class="container mx-auto px-4 py-8">
42
+ <h1 class="text-3xl font-bold mb-6 text-orange-400">Latency Monitoring Dashboard</h1>
43
+
44
+ <div class="grid grid-cols-1 lg:grid-cols-4 gap-6 mb-6">
45
+ <div class="bg-slate-800 p-4 rounded-lg border border-slate-700">
46
+ <h3 class="text-teal-400 font-semibold mb-2">Current Latency</h3>
47
+ <p class="text-2xl font-bold">142.5 <span class="text-sm">ns</span></p>
48
+ </div>
49
+ <div class="bg-slate-800 p-4 rounded-lg border border-slate-700">
50
+ <h3 class="text-teal-400 font-semibold mb-2">24h High</h3>
51
+ <p class="text-2xl font-bold">256.8 <span class="text-sm">ns</span></p>
52
+ </div>
53
+ <div class="bg-slate-800 p-4 rounded-lg border border-slate-700">
54
+ <h3 class="text-teal-400 font-semibold mb-2">24h Low</h3>
55
+ <p class="text-2xl font-bold">98.3 <span class="text-sm">ns</span></p>
56
+ </div>
57
+ <div class="bg-slate-800 p-4 rounded-lg border border-slate-700">
58
+ <h3 class="text-teal-400 font-semibold mb-2">Avg Volume</h3>
59
+ <p class="text-2xl font-bold">1.24M</p>
60
+ </div>
61
+ </div>
62
+
63
+ <div class="bg-slate-800 p-4 rounded-lg border border-slate-700 mb-6">
64
+ <div class="flex justify-between items-center mb-4">
65
+ <h2 class="text-xl font-semibold text-orange-400">Latency Candlestick Chart</h2>
66
+ <div class="flex space-x-2">
67
+ <button class="bg-slate-700 hover:bg-slate-600 px-3 py-1 rounded text-sm">1D</button>
68
+ <button class="bg-orange-500 hover:bg-orange-600 px-3 py-1 rounded text-sm">1H</button>
69
+ <button class="bg-slate-700 hover:bg-slate-600 px-3 py-1 rounded text-sm">15M</button>
70
+ <button class="bg-slate-700 hover:bg-slate-600 px-3 py-1 rounded text-sm">1M</button>
71
+ </div>
72
+ </div>
73
+
74
+ <div class="chart-container" id="latencyChart"></div>
75
+ <div class="volume-chart" id="volumeChart"></div>
76
+
77
+ <div id="tooltip" class="tooltip"></div>
78
+ <div id="crosshair-line" class="crosshair-line"></div>
79
+ </div>
80
+
81
+ <div class="bg-slate-800 p-4 rounded-lg border border-slate-700">
82
+ <h2 class="text-xl font-semibold text-orange-400 mb-4">Latency Statistics</h2>
83
+ <div class="grid grid-cols-1 md:grid-cols-3 gap-4">
84
+ <div>
85
+ <h3 class="text-teal-400 font-semibold mb-2">Percentiles</h3>
86
+ <div class="space-y-1">
87
+ <div class="flex justify-between">
88
+ <span>P99:</span>
89
+ <span class="font-mono">245.7 ns</span>
90
+ </div>
91
+ <div class="flex justify-between">
92
+ <span>P95:</span>
93
+ <span class="font-mono">198.3 ns</span>
94
+ </div>
95
+ <div class="flex justify-between">
96
+ <span>P90:</span>
97
+ <span class="font-mono">175.2 ns</span>
98
+ </div>
99
+ <div class="flex justify-between">
100
+ <span>P50:</span>
101
+ <span class="font-mono">142.1 ns</span>
102
+ </div>
103
+ </div>
104
+ </div>
105
+ <div>
106
+ <h3 class="text-teal-400 font-semibold mb-2">Thresholds</h3>
107
+ <div class="space-y-1">
108
+ <div class="flex justify-between">
109
+ <span class="text-green-400">Optimal:</span>
110
+ <span class="font-mono">&lt; 150 ns</span>
111
+ </div>
112
+ <div class="flex justify-between">
113
+ <span class="text-yellow-400">Warning:</span>
114
+ <span class="font-mono">150-200 ns</span>
115
+ </div>
116
+ <div class="flex justify-between">
117
+ <span class="text-red-400">Critical:</span>
118
+ <span class="font-mono">&gt; 200 ns</span>
119
+ </div>
120
+ </div>
121
+ </div>
122
+ <div>
123
+ <h3 class="text-teal-400 font-semibold mb-2">Recent Events</h3>
124
+ <div class="space-y-1 text-sm">
125
+ <div class="flex justify-between">
126
+ <span>12:45:23</span>
127
+ <span class="text-red-400">Spike: 256.8 ns</span>
128
+ </div>
129
+ <div class="flex justify-between">
130
+ <span>11:22:10</span>
131
+ <span class="text-yellow-400">Warning: 198.5 ns</span>
132
+ </div>
133
+ <div class="flex justify-between">
134
+ <span>09:15:47</span>
135
+ <span class="text-green-400">Optimal: 132.7 ns</span>
136
+ </div>
137
+ </div>
138
+ </div>
139
+ </div>
140
+ </div>
141
+ </div>
142
+
143
+ <script>
144
+ document.addEventListener('DOMContentLoaded', function() {
145
+ // Generate mock data for 24 hours (1-second intervals)
146
+ const now = new Date();
147
+ const startTime = new Date(now);
148
+ startTime.setHours(now.getHours() - 24);
149
+
150
+ const latencyData = [];
151
+ const volumeData = [];
152
+
153
+ for (let i = 0; i < 86400; i++) { // 86400 seconds in 24 hours
154
+ const time = new Date(startTime);
155
+ time.setSeconds(time.getSeconds() + i);
156
+
157
+ // Base latency with some randomness
158
+ let baseLatency = 100 + Math.random() * 50;
159
+
160
+ // Add some spikes
161
+ if (i % 1000 === 0) baseLatency += Math.random() * 100;
162
+ if (i % 5000 === 0) baseLatency += Math.random() * 150;
163
+
164
+ // Generate OHLC values
165
+ const open = baseLatency + (Math.random() * 20 - 10);
166
+ const high = open + Math.random() * 15;
167
+ const low = open - Math.random() * 15;
168
+ const close = open + (Math.random() * 10 - 5);
169
+
170
+ // Generate volume
171
+ const volume = 500000 + Math.random() * 1500000;
172
+
173
+ latencyData.push({
174
+ time: Math.floor(time.getTime() / 1000),
175
+ open: open,
176
+ high: high,
177
+ low: low,
178
+ close: close
179
+ });
180
+
181
+ volumeData.push({
182
+ time: Math.floor(time.getTime() / 1000),
183
+ value: volume,
184
+ color: close > open ? 'rgba(16, 185, 129, 0.8)' : 'rgba(239, 68, 68, 0.8)'
185
+ });
186
+ }
187
+
188
+ // Create charts
189
+ const latencyChart = LightweightCharts.createChart(document.getElementById('latencyChart'), {
190
+ layout: {
191
+ backgroundColor: '#1E293B',
192
+ textColor: '#E2E8F0',
193
+ },
194
+ grid: {
195
+ vertLines: {
196
+ color: '#334155',
197
+ },
198
+ horzLines: {
199
+ color: '#334155',
200
+ },
201
+ },
202
+ crosshair: {
203
+ mode: LightweightCharts.CrosshairMode.Normal,
204
+ },
205
+ rightPriceScale: {
206
+ borderColor: '#334155',
207
+ scaleMargins: {
208
+ top: 0.1,
209
+ bottom: 0.1,
210
+ },
211
+ },
212
+ leftPriceScale: {
213
+ visible: true,
214
+ borderColor: '#334155',
215
+ scaleMargins: {
216
+ top: 0.1,
217
+ bottom: 0.1,
218
+ },
219
+ },
220
+ timeScale: {
221
+ borderColor: '#334155',
222
+ timeVisible: true,
223
+ secondsVisible: true,
224
+ },
225
+ });
226
+
227
+ const volumeChart = LightweightCharts.createChart(document.getElementById('volumeChart'), {
228
+ layout: {
229
+ backgroundColor: '#1E293B',
230
+ textColor: '#E2E8F0',
231
+ },
232
+ grid: {
233
+ vertLines: {
234
+ color: '#334155',
235
+ },
236
+ horzLines: {
237
+ color: '#334155',
238
+ },
239
+ },
240
+ rightPriceScale: {
241
+ visible: false,
242
+ },
243
+ leftPriceScale: {
244
+ visible: false,
245
+ },
246
+ timeScale: {
247
+ borderColor: '#334155',
248
+ },
249
+ height: 120,
250
+ });
251
+
252
+ // Add series to charts
253
+ const candleSeries = latencyChart.addCandlestickSeries({
254
+ upColor: '#10B981',
255
+ downColor: '#EF4444',
256
+ borderDownColor: '#EF4444',
257
+ borderUpColor: '#10B981',
258
+ wickDownColor: '#EF4444',
259
+ wickUpColor: '#10B981',
260
+ priceScaleId: 'left',
261
+ });
262
+
263
+ const volumeSeries = volumeChart.addHistogramSeries({
264
+ color: '#3B82F6',
265
+ priceFormat: {
266
+ type: 'volume',
267
+ },
268
+ priceScaleId: 'left',
269
+ });
270
+
271
+ // Set data
272
+ candleSeries.setData(latencyData);
273
+ volumeSeries.setData(volumeData);
274
+
275
+ // Synchronize time scales
276
+ latencyChart.timeScale().subscribeVisibleTimeRangeChange((timeRange) => {
277
+ volumeChart.timeScale().setVisibleRange(timeRange);
278
+ });
279
+
280
+ // Crosshair and tooltip handling
281
+ const tooltip = document.getElementById('tooltip');
282
+ const crosshairLine = document.getElementById('crosshair-line');
283
+
284
+ latencyChart.subscribeCrosshairMove((param) => {
285
+ if (!param.time || param.point.x < 0 || param.point.x > latencyChart.clientWidth) {
286
+ tooltip.style.opacity = '0';
287
+ crosshairLine.style.opacity = '0';
288
+ return;
289
+ }
290
+
291
+ const candleData = param.seriesData.get(candleSeries);
292
+ const volumeData = param.seriesData.get(volumeSeries);
293
+
294
+ if (!candleData || !volumeData) {
295
+ tooltip.style.opacity = '0';
296
+ crosshairLine.style.opacity = '0';
297
+ return;
298
+ }
299
+
300
+ // Update crosshair line
301
+ crosshairLine.style.left = param.point.x + 'px';
302
+ crosshairLine.style.top = '0';
303
+ crosshairLine.style.height = latencyChart.clientHeight + 'px';
304
+ crosshairLine.style.opacity = '1';
305
+
306
+ // Update tooltip
307
+ const date = new Date(param.time * 1000);
308
+ const timeStr = date.toLocaleTimeString();
309
+
310
+ let color = '#10B981';
311
+ if (candleData.close < candleData.open) {
312
+ color = '#EF4444';
313
+ }
314
+
315
+ tooltip.innerHTML = `
316
+ <div class="text-xs text-slate-300">${timeStr}</div>
317
+ <div class="flex items-center mt-1">
318
+ <div class="w-3 h-3 rounded-full mr-2" style="background-color: ${color}"></div>
319
+ <div>
320
+ <div>O: <span class="font-mono">${candleData.open.toFixed(2)} ns</span></div>
321
+ <div>H: <span class="font-mono">${candleData.high.toFixed(2)} ns</span></div>
322
+ <div>L: <span class="font-mono">${candleData.low.toFixed(2)} ns</span></div>
323
+ <div>C: <span class="font-mono">${candleData.close.toFixed(2)} ns</span></div>
324
+ <div class="mt-1">Volume: <span class="font-mono">${(volumeData.value / 1000000).toFixed(2)}M</span></div>
325
+ </div>
326
+ </div>
327
+ `;
328
+
329
+ tooltip.style.opacity = '1';
330
+ tooltip.style.left = param.point.x + 10 + 'px';
331
+ tooltip.style.top = '20px';
332
+ });
333
+
334
+ // Add some threshold lines
335
+ const optimalLine = latencyChart.addLineSeries({
336
+ color: '#10B981',
337
+ lineWidth: 1,
338
+ lineStyle: 2, // dashed
339
+ priceScaleId: 'left',
340
+ });
341
+ optimalLine.setData([{ time: latencyData[0].time, value: 150 }, { time: latencyData[latencyData.length - 1].time, value: 150 }]);
342
+
343
+ const warningLine = latencyChart.addLineSeries({
344
+ color: '#F59E0B',
345
+ lineWidth: 1,
346
+ lineStyle: 2, // dashed
347
+ priceScaleId: 'left',
348
+ });
349
+ warningLine.setData([{ time: latencyData[0].time, value: 200 }, { time: latencyData[latencyData.length - 1].time, value: 200 }]);
350
+
351
+ // Fit content
352
+ latencyChart.timeScale().fitContent();
353
+ volumeChart.timeScale().fitContent();
354
+ });
355
+ </script>
356
+ <p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=shadadaab/latency-chart" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
357
+ </html>