# Testing Devices That Share a Computer A lab usually runs one device server per instrument, several of them on one computer. Their network ports never get in each other's way, but the instruments behind them share the computer's USB controller, processor and disk, and a test of one device at a time cannot see that. `ConcurrentFieldTest`, in `plesty.lib.test.field_test_concurrency`, runs checks from [Testing on the Instrument](field_test.md) on each device **alone**, then on **all of them at once**, and compares how long each command took. A command that slows down only while its neighbours are busy points at something the devices share, not at the device module. ```python from plesty.lib.test.field_test import FieldTestPipeline from plesty.lib.test.field_test_concurrency import ConcurrentFieldTest comparison = ConcurrentFieldTest( { "rotator": FieldTestPipeline(K10CR1, "COM3", repetitions=50), "powermeter": FieldTestPipeline(PM100D, "USB0::0x1313::0x8078::P1::INSTR", repetitions=50), }, tolerance=0.10, report_path="reports/concurrency-labhost", ).run() raise SystemExit(0 if comparison.ok else 1) ``` For each device and command, the comparison reports the median and 95th-percentile time alone and together, their ratio, and how often the command failed in each case. A command counts as slowed down when its median grows by more than `tolerance` (10 % here), or when it fails only when the others are running. `overlap_fraction` says how much of the "together" phase really had every device running at once. A low value means the devices hardly overlapped, and the comparison understates the problem: give each pipeline enough `repetitions` that it runs for several seconds alone. | Argument | Default | Meaning | |---|---|---| | the pipelines | | one `FieldTestPipeline` per device, by name | | `gates` | `("stability",)` | which checks to run alone and together | | `tolerance` | `0.1` | how much slower, as a fraction, a command may get together | | `settle_s` | `2.0` | pause between the "alone" runs and the "together" run | | `report_path` | `None` | where to write the comparison |