-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_debug_downsample.py
More file actions
42 lines (34 loc) · 1.04 KB
/
test_debug_downsample.py
File metadata and controls
42 lines (34 loc) · 1.04 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
"""Debug downsample test"""
import time
from main import _query_data_impl, state
# 清空缓冲区
with state.buffer_lock:
state.data_buffer.clear()
# 注入数据
base_time = time.time()
test_data = []
for i in range(10):
ts = base_time + i * 0.1
time_str = time.strftime("%H:%M:%S", time.localtime(ts))
ms = int((ts % 1) * 1000)
formatted_time = f"{time_str}.{ms:03d}"
test_data.append((ts, formatted_time, f"{1000 + i}, {i}, {i * 2}"))
with state.buffer_lock:
for item in test_data:
state.data_buffer.append(item)
print(f"Injected {len(test_data)} entries")
print(f"Buffer size: {len(state.data_buffer)}")
# 查询
result = _query_data_impl(max_points=5)
print("\nResult:")
print(result)
# 分析
lines = result.split("\n")
print(f"\nTotal lines: {len(lines)}")
for i, line in enumerate(lines):
print(f" [{i}] {repr(line)}")
# 数据行
print("\nData rows (lines without --- and without : in content):")
for line in lines:
if line and not line.startswith("---") and ":" not in line:
print(f" {line}")