Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f5d30cd

Browse files
committedFeb 17, 2025··
Combine with existing test methods module
1 parent ceb83e5 commit f5d30cd

File tree

5 files changed

+17
-26
lines changed

5 files changed

+17
-26
lines changed
 

‎test_work/__init__.py

-1
This file was deleted.

‎test_work/math.py

-17
This file was deleted.

‎tests/benchmark/pool/test_clear_time.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,5 +31,5 @@ def test_clear_math_by_worker_count(benchmark, workers, with_pool_server):
3131
root_dir = os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(os.path.dirname(__file__)))))
3232
sys.path.append(root_dir)
3333

34-
with with_pool_server(workers, function='lambda: __import__("test_work.math").fibonacci(26)') as pool_server:
34+
with with_pool_server(workers, function='lambda: __import__("tests.data.methods").fibonacci(26)') as pool_server:
3535
benchmark(pool_server.run_benchmark_test, pool_server.queue_in, pool_server.queue_out, 100)

‎tests/data/methods.py

+16
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,19 @@ def sleep_queue_one(seconds=1):
2626
@task(queue='test_channel')
2727
def print_hello():
2828
print('hello world!!')
29+
30+
# fibonacci is a slow method in raw processing power
31+
# demo values - times n in seconds
32+
# 30 - 0.052
33+
# 29 - 0.035
34+
# 28 - 0.024
35+
# 27 - 0.015
36+
# 26 - 0.012
37+
# 25 - 0.0097
38+
39+
@task(queue='test_channel')
40+
def fibonacci(n):
41+
if n <= 1:
42+
return n
43+
else:
44+
return fibonacci(n-1) + fibonacci(n-2)

‎tools/write_messages.py

-7
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717

1818
from test_methods import sleep_function, sleep_discard, task_has_timeout, hello_world_binder
1919

20-
import os, sys
21-
22-
sys.path.append(os.path.dirname(os.path.dirname(__file__)))
23-
24-
from test_work.math import fibonacci
2520

2621
# Database connection details
2722
CONNECTION_STRING = "dbname=dispatch_db user=dispatch password=dispatching host=localhost port=55777"
@@ -41,8 +36,6 @@ def main():
4136
publish_message(channel, message, config={'conninfo': CONNECTION_STRING})
4237
# await send_notification(channel, message)
4338

44-
fibonacci.apply_async(args=[29], config={'conninfo': CONNECTION_STRING})
45-
4639
# send more than number of workers quickly
4740
print('')
4841
print('writing 15 messages fast')

0 commit comments

Comments
 (0)
Please sign in to comment.