Browse Source

Adding a test for checking on the latency when used timeout and queue at the same time

tags/v0.3.10-rc0
haixuantao 11 months ago
parent
commit
6f598ebb44
3 changed files with 64 additions and 0 deletions
  1. +14
    -0
      tests/queue_size_and_timeout_test_python/dataflow.yaml
  2. +32
    -0
      tests/queue_size_and_timeout_test_python/receive_data.py
  3. +18
    -0
      tests/queue_size_and_timeout_test_python/send_data.py

+ 14
- 0
tests/queue_size_and_timeout_test_python/dataflow.yaml View File

@@ -0,0 +1,14 @@
nodes:
- id: send_data
path: ./send_data.py
inputs:
keepalive: dora/timer/millis/100000
outputs:
- ts

- id: receive_data_with_sleep
path: ./receive_data.py
inputs:
ts:
source: send_data/ts
queue_size: 1

+ 32
- 0
tests/queue_size_and_timeout_test_python/receive_data.py View File

@@ -0,0 +1,32 @@
import time

from dora import Node


def main() -> None:
dora_node = Node()

i = 0
while True:
message = dora_node.next(timeout=0.001)

if message is None:
break

if message["type"] != "INPUT":
continue
sent = message["value"][0].as_py()
sent_in_s = sent / 1_000_000
received = time.perf_counter_ns()
received_in_s = received / 1_000_000

i += 1
print(
f"[{i}] Sent: {sent_in_s}, Received: {received_in_s}, Difference: {received_in_s - sent_in_s}"
)
assert received_in_s - sent_in_s < 0.1
time.sleep(0.1)


if __name__ == "__main__":
main()

+ 18
- 0
tests/queue_size_and_timeout_test_python/send_data.py View File

@@ -0,0 +1,18 @@
import time

import pyarrow as pa
from dora import Node


def main() -> None:
dora_node = Node()
i = 0
while True:
dora_node.send_output("ts", pa.array([time.perf_counter_ns()]))
i += 1
# print(f"Sent {i} times", flush=True)
time.sleep(0.001)


if __name__ == "__main__":
main()

Loading…
Cancel
Save