-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_debug.py
More file actions
37 lines (30 loc) · 1011 Bytes
/
test_debug.py
File metadata and controls
37 lines (30 loc) · 1011 Bytes
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
"""调试降采样"""
import time
from main import state, _query_data_impl
# 添加10条测试数据
print("Adding 10 test data entries...")
base_time = time.time()
test_data = []
for i in range(10):
ts = base_time + i * 0.001
time_str = time.strftime("%H:%M:%S", time.localtime(ts))
ms = int((ts % 1) * 1000)
formatted = f"{time_str}.{ms:03d}"
print(f" {i}: ts={ts}, time={formatted}")
test_data.append((ts, formatted, f"{1000 + i}, {i}, {i * 2}"))
with state.buffer_lock:
state.data_buffer.clear()
for item in test_data:
state.data_buffer.append(item)
print(f"\nBuffer size: {len(state.data_buffer)}")
# 查询
print("\nQuerying all data:")
result = _query_data_impl()
print(result)
# 查询5条(降采样)
print("\nQuerying max_points=5:")
result = _query_data_impl(max_points=5)
print(result)
lines = [l for l in result.split("\n") if l and not l.startswith("-") and ":" not in l]
print(f"Total lines: {len(lines)}")
print(f"Data rows: {len(lines) - 1}")