This commit is contained in:
@@ -10,26 +10,27 @@ from slic.utils.hastyepics import *
|
||||
from unittest.mock import patch
|
||||
|
||||
def test_motor_instantiation_fast_vs_epics():
|
||||
# Configuration of mock for epics.Motor
|
||||
with patch('epics.Motor.get') as mock_get:
|
||||
mock_get.return_value = 'motor' # Simulate a real motor
|
||||
|
||||
fast_times = []
|
||||
slow_times = []
|
||||
|
||||
# Mean of 10 runs
|
||||
for _ in range(10):
|
||||
t0 = time.perf_counter()
|
||||
m_fast = Motor("TEST:MOTOR_t1")
|
||||
t1 = time.perf_counter()
|
||||
|
||||
|
||||
t0 = time.time()
|
||||
m_fast = Motor("TEST:MOTOR_t1") # Fast version
|
||||
t1 = time.time()
|
||||
t2 = time.perf_counter()
|
||||
m_slow = epics.Motor("TEST:MOTOR_t2")
|
||||
t3 = time.perf_counter()
|
||||
|
||||
t2 = time.time()
|
||||
m_slow = epics.Motor("TEST:MOTOR_t2") # EPICS version
|
||||
t3 = time.time()
|
||||
|
||||
# Make sure both are valid PVs
|
||||
assert m_fast is not None
|
||||
assert m_slow is not None
|
||||
|
||||
assert (t1 - t0) < (t3 - t2)
|
||||
|
||||
|
||||
fast_times.append(t1 - t0)
|
||||
slow_times.append(t3 - t2)
|
||||
|
||||
avg_fast = sum(fast_times) / len(fast_times)
|
||||
avg_slow = sum(slow_times) / len(slow_times)
|
||||
|
||||
assert avg_fast < avg_slow, f"Fast version ({avg_fast:.6f}s) should be faster than EPICS ({avg_slow:.6f}s)"
|
||||
|
||||
def test_motor_without_suffix_and_dot():
|
||||
# Suffix .VAL ... dot should be stripped from name
|
||||
|
||||
Reference in New Issue
Block a user