Skip to content

Conversation

EnYi-ni
Copy link
Collaborator

@EnYi-ni EnYi-ni commented Oct 10, 2025

  • This contribution adheres to CONTRIBUTING.md.

  • I've updated CHANGELOG.md, under "Resolved Issues".

  • I've added tests applicable for this pull request

What does this Pull Request accomplish?

Speed up channel reader and writer verify function to resolve functions that bottleneck at this verify function. Improved functions: analog and digital read_many_sample, digital write_many_sample

Analog write does not benefit as much as its bottleneck is in its write function instead of the verify function.

Why should this Pull Request be merged?

Fixes #843
AB#3330619

What testing has been done?

Selective benchmark that involves the verify function in a local test machine: PXIE8880, Windows 10 Enterprise, niDAQmx 2025 Q3

Analog Stream Read Test

Before

PS C:\Users\Administrator\dev\nidaqmx-python> poetry run pytest .\tests\benchmark\test_analog_stream_readers.py -k "library and read_many_sample"
============================================================================================== test session starts ==============================================================================================
platform win32 -- Python 3.11.9, pytest-8.4.2, pluggy-1.6.0
benchmark: 5.1.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: C:\Users\Administrator\dev\nidaqmx-python
configfile: pyproject.toml
plugins: benchmark-5.1.0, cov-7.0.0, mock-3.15.1
collected 72 items / 64 deselected / 8 selected

tests\benchmark\test_analog_stream_readers.py ........                                                                                                                                                     [100%]


-------------------------------------------------------------------------------------------------------------- benchmark 'analog_readers': 8 tests --------------------------------------------------------------------------------------------------------------
Name (time in us)                                                                         Min                    Max               Mean              StdDev             Median                IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1-1]        51.3000 (1.0)       2,212.9000 (10.59)    59.9509 (1.07)      24.0747 (2.61)     58.2000 (1.10)      8.1000 (8.10)      306;686       16.6803 (0.93)      10000           1
test___analog_single_channel_reader___read_many_sample[library_init_kwargs-1]         51.5000 (1.00)        209.0000 (1.0)      55.8751 (1.0)        9.2136 (1.0)      53.0000 (1.0)       1.3000 (1.30)      194;478       17.8971 (1.0)        2328           1
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1000-1]     54.5000 (1.06)     13,369.4000 (63.97)    60.0270 (1.07)     133.2988 (14.47)    56.3000 (1.06)      1.0000 (1.0)        4;1383       16.6592 (0.93)      10021           1
test___analog_single_channel_reader___read_many_sample[library_init_kwargs-1000]      54.6000 (1.06)        501.1000 (2.40)     64.9004 (1.16)      13.4271 (1.46)     62.4000 (1.18)      8.6750 (8.67)      356;338       15.4082 (0.86)       5059           1
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1-2]        55.0000 (1.07)        264.9000 (1.27)     60.1551 (1.08)      10.1062 (1.10)     56.6000 (1.07)      5.5000 (5.50)      383;403       16.6237 (0.93)       4931           1
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1000-2]     57.6000 (1.12)        291.4000 (1.39)     62.7871 (1.12)      10.1989 (1.11)     59.5000 (1.12)      3.2000 (3.20)      466;784       15.9268 (0.89)       6444           1
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1-8]        71.1000 (1.39)        225.0000 (1.08)     76.4293 (1.37)      10.9274 (1.19)     72.7000 (1.37)      1.3000 (1.30)     571;1200       13.0840 (0.73)       6274           1
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1000-8]     79.8000 (1.56)        372.3000 (1.78)     90.9129 (1.63)      14.0441 (1.52)     85.6000 (1.62)     14.3000 (14.30)     427;133       10.9995 (0.61)       3406           1
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
======================================================================================= 8 passed, 64 deselected in 5.78s ========================================================================================

After

PS C:\Users\Administrator\dev\nidaqmx-python> poetry run pytest .\tests\benchmark\test_analog_stream_readers.py -k "library and read_many_sample"
============================================================================================== test session starts ==============================================================================================
platform win32 -- Python 3.11.9, pytest-8.4.2, pluggy-1.6.0
benchmark: 5.1.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: C:\Users\Administrator\dev\nidaqmx-python
configfile: pyproject.toml
plugins: benchmark-5.1.0, cov-7.0.0, mock-3.15.1
collected 72 items / 64 deselected / 8 selected

tests\benchmark\test_analog_stream_readers.py ........                                                                                                                                                     [100%]


------------------------------------------------------------------------------------------------------------- benchmark 'analog_readers': 8 tests --------------------------------------------------------------------------------------------------------------
Name (time in us)                                                                         Min                    Max               Mean              StdDev             Median               IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1-1]        21.4000 (1.0)         237.2000 (1.36)     24.2129 (1.04)       6.7482 (1.07)     22.2000 (1.0)      2.7000 (6.75)      613;717       41.3003 (0.97)      11535           1
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1-2]        21.5000 (1.00)     15,109.3000 (86.64)    27.2798 (1.17)     126.1403 (20.05)    25.1000 (1.13)     1.7000 (4.25)       9;1938       36.6572 (0.86)      14348           1
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1-8]        21.5000 (1.00)        266.7000 (1.53)     23.5703 (1.01)       6.5858 (1.05)     22.3000 (1.00)     0.5000 (1.25)     534;2566       42.4262 (0.99)      14904           1
test___analog_single_channel_reader___read_many_sample[library_init_kwargs-1]         21.5000 (1.00)        179.3000 (1.03)     23.3713 (1.0)        6.2909 (1.0)      22.2000 (1.0)      0.4000 (1.0)        78;310       42.7875 (1.0)        2164           1
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1000-1]     24.0000 (1.12)        174.4000 (1.0)      26.2872 (1.12)       6.4026 (1.02)     24.9000 (1.12)     0.4000 (1.0)      684;2779       38.0414 (0.89)      16261           1
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1000-2]     24.1000 (1.13)        366.3000 (2.10)     29.0513 (1.24)       9.6102 (1.53)     27.4000 (1.23)     3.3000 (8.25)    1000;1315       34.4219 (0.80)      12920           1
test___analog_single_channel_reader___read_many_sample[library_init_kwargs-1000]      24.1000 (1.13)        400.5000 (2.30)     28.8999 (1.24)       8.4723 (1.35)     27.6000 (1.24)     4.0000 (10.00)     741;924       34.6021 (0.81)       9804           1
test___analog_multi_channel_reader___read_many_sample[library_init_kwargs-1000-8]     30.3000 (1.42)        279.0000 (1.60)     34.6007 (1.48)       7.8253 (1.24)     32.6000 (1.47)     4.9000 (12.25)     416;363       28.9011 (0.68)       7289           1
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
======================================================================================= 8 passed, 64 deselected in 5.11s ========================================================================================

Digital Stream Read Test

Before

PS C:\Users\Administrator\dev\nidaqmx-python> poetry run pytest .\tests\benchmark\test_digital_stream_readers.py -k "library and read_many_sample"
=============================================================================================== test session starts ===============================================================================================
platform win32 -- Python 3.11.9, pytest-8.4.2, pluggy-1.6.0
benchmark: 5.1.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: C:\Users\Administrator\dev\nidaqmx-python
configfile: pyproject.toml
plugins: benchmark-5.1.0, cov-7.0.0, mock-3.15.1
collected 76 items / 72 deselected / 4 selected

tests\benchmark\test_digital_stream_readers.py ....                                                                                                                                                          [100%]


------------------------------------------------------------------------------------------------------------------ benchmark 'digital_readers': 4 tests ------------------------------------------------------------------------------------------------------------------
Name (time in us)                                                                                    Min                   Max               Mean             StdDev             Median                IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test___digital_single_channel_reader___read_many_sample_port_uint32[library_init_kwargs-1]       50.8000 (1.0)        192.1000 (1.0)      55.1201 (1.0)       9.3601 (1.0)      52.6000 (1.0)       1.2000 (1.0)       132;317       18.1422 (1.0)        2046           1
test___digital_multi_channel_reader___read_many_sample_port_uint32[library_init_kwargs-1]        51.5000 (1.01)       234.1000 (1.22)     58.4504 (1.06)     10.3220 (1.10)     54.2000 (1.03)      7.1000 (5.92)      785;661       17.1085 (0.94)       8258           1
test___digital_multi_channel_reader___read_many_sample_port_uint32[library_init_kwargs-100]      52.8000 (1.04)     2,269.7000 (11.82)    62.2310 (1.13)     26.9867 (2.88)     60.0000 (1.14)      9.0000 (7.50)      189;511       16.0692 (0.89)       8170           1
test___digital_single_channel_reader___read_many_sample_port_uint32[library_init_kwargs-100]     53.0000 (1.04)       668.0000 (3.48)     63.2198 (1.15)     14.8246 (1.58)     60.5000 (1.15)     11.3000 (9.42)      373;271       15.8178 (0.87)       4742           1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
======================================================================================== 4 passed, 72 deselected in 2.84s =========================================================================================

After

PS C:\Users\Administrator\dev\nidaqmx-python> poetry run pytest .\tests\benchmark\test_digital_stream_readers.py -k "library and read_many_sample"
============================================================================================== test session starts ==============================================================================================
platform win32 -- Python 3.11.9, pytest-8.4.2, pluggy-1.6.0
benchmark: 5.1.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: C:\Users\Administrator\dev\nidaqmx-python
configfile: pyproject.toml
plugins: benchmark-5.1.0, cov-7.0.0, mock-3.15.1
collected 76 items / 72 deselected / 4 selected

tests\benchmark\test_digital_stream_readers.py ....                                                                                                                                                        [100%]


------------------------------------------------------------------------------------------------------------------- benchmark 'digital_readers': 4 tests ------------------------------------------------------------------------------------------------------------------
Name (time in us)                                                                                    Min                    Max               Mean              StdDev             Median               IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test___digital_multi_channel_reader___read_many_sample_port_uint32[library_init_kwargs-1]        21.8000 (1.0)         192.7000 (1.57)     24.8498 (1.02)       6.6443 (1.16)     22.7000 (1.01)     2.7000 (1.80)      820;917       40.2418 (0.99)      14410           1
test___digital_single_channel_reader___read_many_sample_port_uint32[library_init_kwargs-1]       21.9000 (1.00)        123.0000 (1.0)      24.4777 (1.0)        5.7391 (1.0)      22.5000 (1.0)      2.5000 (1.67)      116;246       40.8536 (1.0)        1732           1
test___digital_single_channel_reader___read_many_sample_port_uint32[library_init_kwargs-100]     23.4000 (1.07)        482.4000 (3.92)     27.8669 (1.14)       9.1647 (1.60)     26.6000 (1.18)     4.4000 (2.93)      654;762       35.8849 (0.88)       8511           1
test___digital_multi_channel_reader___read_many_sample_port_uint32[library_init_kwargs-100]      23.5000 (1.08)     16,182.1000 (131.56)   29.5174 (1.21)     128.7273 (22.43)    27.2000 (1.21)     1.5000 (1.0)        6;4567       33.8784 (0.83)      16001           1
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
======================================================================================= 4 passed, 72 deselected in 2.58s ========================================================================================

Digital Stream Write Test

Before

PS C:\Users\Administrator\dev\nidaqmx-python> poetry run pytest .\tests\benchmark\test_digital_stream_writers.py -k "library"
=============================================================================================== test session starts ===============================================================================================
platform win32 -- Python 3.11.9, pytest-8.4.2, pluggy-1.6.0
benchmark: 5.1.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: C:\Users\Administrator\dev\nidaqmx-python
configfile: pyproject.toml
plugins: benchmark-5.1.0, cov-7.0.0, mock-3.15.1
collected 76 items / 38 deselected / 38 selected

tests\benchmark\test_digital_stream_writers.py ......................................                                                                                                                        [100%]


-------------------------------------------------------------------------------------------------------------------- benchmark 'digital_writers': 38 tests ---------------------------------------------------------------------------------------------------------------------
Name (time in us)                                                                                      Min                    Max                Mean              StdDev              Median                IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test___digital_single_channel_writer___write_one_sample_one_line[library_init_kwargs]              14.4000 (1.0)         429.0000 (2.45)      15.9721 (1.0)        8.9065 (1.11)      15.0000 (1.0)       0.3000 (1.0)        69;520       62.6092 (1.0)        3022           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-8-1]               23.4000 (1.63)        185.0000 (1.05)      26.1419 (1.64)       8.2649 (1.03)      24.5000 (1.63)      0.9000 (3.00)     565;2311       38.2527 (0.61)      12675           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-1-1]               23.5000 (1.63)     13,802.1000 (78.69)     29.1274 (1.82)     186.0710 (23.21)     24.7000 (1.65)      1.2000 (4.00)        1;926       34.3319 (0.55)       5492           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-2-1]               23.6000 (1.64)        185.2000 (1.06)      26.8933 (1.68)       8.6250 (1.08)      24.6000 (1.64)      1.4000 (4.67)    1145;2957       37.1840 (0.59)      18282           1
test___digital_single_channel_writer___write_waveform_port[library_init_kwargs-1]                  23.7000 (1.65)        217.8000 (1.24)      26.4478 (1.66)       8.2998 (1.04)      24.9000 (1.66)      0.7000 (2.33)     727;3202       37.8103 (0.60)      17922           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-1-100]             24.4000 (1.69)        196.3000 (1.12)      27.1672 (1.70)       8.4082 (1.05)      25.6000 (1.71)      0.7000 (2.33)     524;1889       36.8091 (0.59)      12346           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-2-100]             24.6000 (1.71)        175.4000 (1.0)       27.2568 (1.71)       8.0184 (1.0)       25.7000 (1.71)      0.7000 (2.33)     714;2617       36.6881 (0.59)      15749           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-8-100]             25.6000 (1.78)        182.4000 (1.04)      28.2267 (1.77)       8.3283 (1.04)      26.6000 (1.77)      0.6000 (2.00)     698;2474       35.4274 (0.57)      15626           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-8-1-1]              30.9000 (2.15)        238.5000 (1.36)      34.5559 (2.16)       9.1580 (1.14)      32.4000 (2.16)      1.0000 (3.33)     772;2831       28.9387 (0.46)      14006           1
test___digital_single_channel_writer___write_waveform_port[library_init_kwargs-100]                30.9000 (2.15)        199.0000 (1.13)      34.0482 (2.13)       8.6759 (1.08)      32.1000 (2.14)      0.7000 (2.33)     790;2862       29.3702 (0.47)      14948           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-1-1-1]              31.2000 (2.17)        185.1000 (1.06)      35.3667 (2.21)       9.7647 (1.22)      32.8000 (2.19)      2.1000 (7.00)     584;1081       28.2752 (0.45)       9320           1
test___digital_multi_channel_writer___write_waveform_port[library_init_kwargs-1]                   31.2000 (2.17)        202.4000 (1.15)      34.5682 (2.16)       8.7685 (1.09)      32.7000 (2.18)      0.7000 (2.33)     698;2344       28.9283 (0.46)      13813           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-2-1-1]              31.5000 (2.19)        228.9000 (1.31)      34.8536 (2.18)       9.1245 (1.14)      32.8000 (2.19)      0.8000 (2.67)     841;2933       28.6915 (0.46)      15577           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-1-100-1]            32.2000 (2.24)        191.8000 (1.09)      35.4522 (2.22)       8.6863 (1.08)      33.6000 (2.24)      0.9000 (3.00)     713;2504       28.2070 (0.45)      13569           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-2-100-1]            32.4000 (2.25)        266.9000 (1.52)      39.2673 (2.46)      11.3465 (1.42)      37.3000 (2.49)      4.7000 (15.67)     491;945       25.4665 (0.41)       8533           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-1-1-2]              32.7000 (2.27)        201.3000 (1.15)      36.6071 (2.29)       9.3534 (1.17)      34.5000 (2.30)      1.1000 (3.67)     672;2264       27.3171 (0.44)      12316           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-8-1-2]              32.7000 (2.27)        229.0000 (1.31)      36.5831 (2.29)       9.0767 (1.13)      34.5000 (2.30)      0.9000 (3.00)     749;2549       27.3350 (0.44)      13496           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-2-1-2]              33.2000 (2.31)      1,052.4000 (6.00)      41.5913 (2.60)      16.8677 (2.10)      38.5000 (2.57)      6.3000 (21.00)    636;1413       24.0435 (0.38)      13387           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-8-100-1]            33.6000 (2.33)        203.6000 (1.16)      37.0587 (2.32)       9.0553 (1.13)      35.0000 (2.33)      0.8000 (2.67)     734;2368       26.9842 (0.43)      13459           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-1-100-2]            34.4000 (2.39)        226.4000 (1.29)      37.9684 (2.38)       9.3177 (1.16)      35.8000 (2.39)      0.9000 (3.00)     597;2021       26.3377 (0.42)      10696           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-2-100-2]            34.5000 (2.40)        260.4000 (1.48)      38.9071 (2.44)      10.1426 (1.26)      36.2000 (2.41)      3.1000 (10.33)    680;1064       25.7022 (0.41)      11014           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-8-100-2]            37.2000 (2.58)        217.2000 (1.24)      40.8987 (2.56)       9.3982 (1.17)      38.8000 (2.59)      0.9000 (3.00)     711;2053       24.4507 (0.39)      12691           1
test___digital_multi_channel_writer___write_waveform_port[library_init_kwargs-100]                 39.2000 (2.72)        211.4000 (1.21)      42.8788 (2.68)       9.4444 (1.18)      40.7000 (2.71)      0.8000 (2.67)     667;1901       23.3215 (0.37)      11561           1
test___digital_multi_channel_writer___write_many_sample_port_uint32[library_init_kwargs-1]         54.3000 (3.77)        215.7000 (1.23)      60.2004 (3.77)      10.2517 (1.28)      57.1000 (3.81)      1.6000 (5.33)     644;1743       16.6112 (0.27)       8279           1
test___digital_single_channel_writer___write_many_sample_port_uint32[library_init_kwargs-1]        54.9000 (3.81)        214.6000 (1.22)      59.5858 (3.73)       9.4598 (1.18)      56.9000 (3.79)      1.3000 (4.33)      398;852       16.7825 (0.27)       4944           1
test___digital_single_channel_writer___write_many_sample_port_uint32[library_init_kwargs-100]      55.9000 (3.88)        277.2000 (1.58)      60.6249 (3.80)       9.6143 (1.20)      58.0000 (3.87)      1.0000 (3.33)     681;1560       16.4949 (0.26)       9434           1
test___digital_multi_channel_writer___write_many_sample_port_uint32[library_init_kwargs-100]       56.1000 (3.90)        247.3000 (1.41)      61.3999 (3.84)      10.4863 (1.31)      58.2000 (3.88)      1.5000 (5.00)     516;1332       16.2867 (0.26)       6486           1
test___digital_multi_channel_writer___write_one_sample_one_line[library_init_kwargs-1]             59.9000 (4.16)        226.6000 (1.29)      64.7535 (4.05)       9.9046 (1.24)      62.0000 (4.13)      1.2000 (4.00)     487;1251       15.4432 (0.25)       6998           1
test___digital_single_channel_writer___write_one_sample_multi_line[library_init_kwargs-1]          60.5000 (4.20)        215.6000 (1.23)      70.8568 (4.44)      14.4013 (1.80)      67.3000 (4.49)     12.0000 (40.00)      161;91       14.1130 (0.23)       1521           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-1-1]         60.6000 (4.21)        257.6000 (1.47)      66.0399 (4.13)      10.7251 (1.34)      62.7000 (4.18)      1.7000 (5.67)     610;1682       15.1424 (0.24)       8020           1
test___digital_multi_channel_writer___write_one_sample_one_line[library_init_kwargs-2]             79.9000 (5.55)        244.6000 (1.39)      85.8839 (5.38)      12.1283 (1.51)      82.1000 (5.47)      1.6000 (5.33)      264;625       11.6436 (0.19)       3497           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-1-2]         80.7000 (5.60)        270.0000 (1.54)      86.8183 (5.44)      12.0864 (1.51)      82.9000 (5.53)      1.6000 (5.33)     558;1185       11.5183 (0.18)       6423           1
test___digital_single_channel_writer___write_one_sample_multi_line[library_init_kwargs-8]          96.3000 (6.69)      2,026.3000 (11.55)    113.5836 (7.11)      30.6109 (3.82)     110.1000 (7.34)     20.3000 (67.67)     292;212        8.8041 (0.14)       5893           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-8-1]         96.5000 (6.70)        266.5000 (1.52)     103.4735 (6.48)      12.4451 (1.55)      98.9000 (6.59)      1.7000 (5.67)     732;1409        9.6643 (0.15)       7236           1
test___digital_single_channel_writer___write_one_sample_multi_line[library_init_kwargs-2]          96.5000 (6.70)        313.5000 (1.79)     108.8797 (6.82)      15.8399 (1.98)     100.7000 (6.71)     15.1000 (50.33)     752;327        9.1844 (0.15)       5808           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-2-1]         97.3000 (6.76)        283.7000 (1.62)     104.0468 (6.51)      13.1025 (1.63)      99.6000 (6.64)      1.7000 (5.67)      496;985        9.6111 (0.15)       5380           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-2-2]        141.5000 (9.83)        384.5000 (2.19)     150.6788 (9.43)      17.4318 (2.17)     144.3000 (9.62)      2.1000 (7.00)      469;833        6.6366 (0.11)       4465           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-8-2]        142.0000 (9.86)        422.9000 (2.41)     151.3589 (9.48)      17.0899 (2.13)     144.4000 (9.63)      2.6500 (8.83)      488;932        6.6068 (0.11)       4152           1
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
======================================================================================= 38 passed, 38 deselected in 20.15s ========================================================================================

After

PS C:\Users\Administrator\dev\nidaqmx-python> poetry run pytest .\tests\benchmark\test_digital_stream_writers.py -k "library"
============================================================================================== test session starts ==============================================================================================
platform win32 -- Python 3.11.9, pytest-8.4.2, pluggy-1.6.0
benchmark: 5.1.0 (defaults: timer=time.perf_counter disable_gc=False min_rounds=5 min_time=0.000005 max_time=1.0 calibration_precision=10 warmup=False warmup_iterations=100000)
rootdir: C:\Users\Administrator\dev\nidaqmx-python
configfile: pyproject.toml
plugins: benchmark-5.1.0, cov-7.0.0, mock-3.15.1
collected 76 items / 38 deselected / 38 selected

tests\benchmark\test_digital_stream_writers.py ......................................                                                                                                                      [100%]


------------------------------------------------------------------------------------------------------------------ benchmark 'digital_writers': 38 tests ------------------------------------------------------------------------------------------------------------------
Name (time in us)                                                                                     Min                    Max               Mean             StdDev             Median               IQR            Outliers  OPS (Kops/s)            Rounds  Iterations
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
test___digital_single_channel_writer___write_one_sample_one_line[library_init_kwargs]             14.1000 (1.0)         434.0000 (2.73)     16.2904 (1.0)       9.6178 (1.59)     14.7000 (1.0)      1.4000 (3.50)      146;234       61.3860 (1.0)        3438           1
test___digital_multi_channel_writer___write_many_sample_port_uint32[library_init_kwargs-1]        14.9000 (1.06)        168.3000 (1.06)     16.7845 (1.03)      6.6123 (1.09)     15.6000 (1.06)     0.5000 (1.25)     404;1962       59.5789 (0.97)      10331           1
test___digital_single_channel_writer___write_many_sample_port_uint32[library_init_kwargs-100]     15.3000 (1.09)        176.5000 (1.11)     18.9246 (1.16)      6.9816 (1.16)     17.8000 (1.21)     1.2000 (3.00)    1153;2076       52.8412 (0.86)      17668           1
test___digital_multi_channel_writer___write_many_sample_port_uint32[library_init_kwargs-100]      15.5000 (1.10)        177.2000 (1.12)     17.2314 (1.06)      6.0426 (1.0)      16.2000 (1.10)     0.4000 (1.0)      479;2293       58.0336 (0.95)      14085           1
test___digital_single_channel_writer___write_many_sample_port_uint32[library_init_kwargs-1]       15.9000 (1.13)        158.8000 (1.0)      18.2259 (1.12)      6.6328 (1.10)     17.1000 (1.16)     1.0000 (2.50)      134;297       54.8671 (0.89)       3054           1
test___digital_multi_channel_writer___write_one_sample_one_line[library_init_kwargs-1]            17.5000 (1.24)        179.8000 (1.13)     19.5125 (1.20)      6.2821 (1.04)     18.4000 (1.25)     0.5000 (1.25)     614;2513       51.2493 (0.83)      16104           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-2-1]        17.6000 (1.25)        174.0000 (1.10)     19.6908 (1.21)      6.4745 (1.07)     18.4000 (1.25)     0.4000 (1.00)     775;3450       50.7852 (0.83)      18349           1
test___digital_multi_channel_writer___write_one_sample_one_line[library_init_kwargs-2]            17.6000 (1.25)        219.1000 (1.38)     19.7568 (1.21)      6.7663 (1.12)     18.4000 (1.25)     0.7000 (1.75)     753;3830       50.6155 (0.82)      18215           1
test___digital_single_channel_writer___write_one_sample_multi_line[library_init_kwargs-2]         17.7000 (1.26)        171.5000 (1.08)     21.5425 (1.32)      7.0126 (1.16)     20.5000 (1.39)     3.0000 (7.50)    1449;1486       46.4198 (0.76)      17794           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-1-1]        17.8000 (1.26)        187.8000 (1.18)     19.5801 (1.20)      6.3229 (1.05)     18.5000 (1.26)     0.4000 (1.0)      615;2765       51.0722 (0.83)      18116           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-1-2]        17.9000 (1.27)        214.2000 (1.35)     20.0128 (1.23)      6.5034 (1.08)     18.7000 (1.27)     0.5000 (1.25)     804;3835       49.9681 (0.81)      18622           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-2-2]        17.9000 (1.27)        190.7000 (1.20)     19.9507 (1.22)      6.4939 (1.07)     18.6000 (1.27)     0.6000 (1.50)     763;3330       50.1235 (0.82)      16807           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-8-1]        17.9000 (1.27)        232.7000 (1.47)     19.6710 (1.21)      6.6557 (1.10)     18.6000 (1.27)     0.4000 (1.0)      535;2339       50.8362 (0.83)      15016           1
test___digital_multi_channel_writer___write_one_sample_multi_line[library_init_kwargs-8-2]        17.9000 (1.27)        174.3000 (1.10)     20.0373 (1.23)      6.8356 (1.13)     18.7000 (1.27)     0.5000 (1.25)     930;3919       49.9068 (0.81)      20662           1
test___digital_single_channel_writer___write_one_sample_multi_line[library_init_kwargs-8]         17.9000 (1.27)     12,852.3000 (80.93)    21.6292 (1.33)     99.6108 (16.48)    18.9000 (1.29)     2.4000 (6.00)      19;1104       46.2338 (0.75)      16667           1
test___digital_single_channel_writer___write_one_sample_multi_line[library_init_kwargs-1]         18.1000 (1.28)        190.9000 (1.20)     20.8900 (1.28)      6.5729 (1.09)     18.9000 (1.29)     2.3000 (5.75)      582;740       47.8697 (0.78)       8341           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-2-1]              22.3000 (1.58)        183.5000 (1.16)     25.2023 (1.55)      8.5049 (1.41)     23.4000 (1.59)     0.8000 (2.00)     851;3190       39.6789 (0.65)      16367           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-8-1]              22.6000 (1.60)        171.8000 (1.08)     25.4476 (1.56)      8.1142 (1.34)     23.7000 (1.61)     0.8000 (2.00)     915;3420       39.2965 (0.64)      16394           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-1-1]              22.7000 (1.61)        193.4000 (1.22)     25.6667 (1.58)      8.8825 (1.47)     23.7000 (1.61)     0.8000 (2.00)     272;1008       38.9610 (0.63)       4843           1
test___digital_single_channel_writer___write_waveform_port[library_init_kwargs-1]                 22.8000 (1.62)        200.1000 (1.26)     25.6977 (1.58)      8.8569 (1.47)     23.9000 (1.63)     0.8000 (2.00)     784;2965       38.9140 (0.63)      16261           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-1-100]            23.3000 (1.65)        170.5000 (1.07)     26.0556 (1.60)      8.0483 (1.33)     24.4000 (1.66)     0.7000 (1.75)     851;3256       38.3795 (0.63)      18316           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-2-100]            23.4000 (1.66)        227.3000 (1.43)     26.2826 (1.61)      8.3230 (1.38)     24.6000 (1.67)     0.8000 (2.00)     766;2977       38.0480 (0.62)      16052           1
test___digital_single_channel_writer___write_waveform_lines[library_init_kwargs-8-100]            24.8000 (1.76)        180.3000 (1.14)     27.4560 (1.69)      8.3146 (1.38)     25.8000 (1.76)     0.6000 (1.50)     583;2061       36.4219 (0.59)      12595           1
test___digital_single_channel_writer___write_waveform_port[library_init_kwargs-100]               29.9000 (2.12)        277.5000 (1.75)     32.8351 (2.02)      8.8517 (1.46)     30.9000 (2.10)     0.7000 (1.75)     742;2486       30.4552 (0.50)      14904           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-1-1-1]             30.0000 (2.13)        203.9000 (1.28)     33.1744 (2.04)      9.0652 (1.50)     31.2000 (2.12)     0.8000 (2.00)     535;1705       30.1438 (0.49)      10289           1
test___digital_multi_channel_writer___write_waveform_port[library_init_kwargs-1]                  30.2000 (2.14)        235.6000 (1.48)     33.4071 (2.05)      9.1194 (1.51)     31.6000 (2.15)     0.8000 (2.00)     648;2040       29.9338 (0.49)      14006           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-8-1-1]             30.2000 (2.14)        216.3000 (1.36)     33.3344 (2.05)      8.9935 (1.49)     31.5000 (2.14)     0.8000 (2.00)     682;2240       29.9990 (0.49)      14368           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-2-1-1]             30.3000 (2.15)        193.3000 (1.22)     33.4994 (2.06)      8.8390 (1.46)     31.7000 (2.16)     0.9000 (2.25)     509;1596       29.8513 (0.49)       9853           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-1-100-1]           31.2000 (2.21)        185.0000 (1.16)     34.7129 (2.13)      9.1857 (1.52)     32.6000 (2.22)     1.1000 (2.75)     772;2612       28.8077 (0.47)      13662           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-2-100-1]           31.3000 (2.22)        286.2000 (1.80)     34.5750 (2.12)      9.0721 (1.50)     32.5000 (2.21)     0.9000 (2.25)     776;2523       28.9226 (0.47)      13794           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-1-1-2]             31.8000 (2.26)        186.5000 (1.17)     35.3098 (2.17)      9.0442 (1.50)     33.3000 (2.27)     0.8000 (2.00)     655;2106       28.3207 (0.46)      11934           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-8-1-2]             32.0000 (2.27)        213.7000 (1.35)     35.7331 (2.19)      9.1420 (1.51)     33.6000 (2.29)     0.9000 (2.25)     793;2393       27.9852 (0.46)      13478           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-2-1-2]             32.3000 (2.29)        205.3000 (1.29)     35.7852 (2.20)      9.0148 (1.49)     33.7000 (2.29)     0.9000 (2.25)     797;2532       27.9445 (0.46)      13870           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-8-100-1]           32.6000 (2.31)        210.4000 (1.32)     36.2203 (2.22)      9.4178 (1.56)     34.0000 (2.31)     1.0000 (2.50)     626;2052       27.6088 (0.45)      10929           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-1-100-2]           33.0000 (2.34)        199.1000 (1.25)     36.4075 (2.23)      9.3191 (1.54)     34.4000 (2.34)     0.8000 (2.00)     686;2148       27.4669 (0.45)      13441           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-2-100-2]           33.6000 (2.38)        230.0000 (1.45)     36.7613 (2.26)      9.1212 (1.51)     34.8000 (2.37)     0.8000 (2.00)     657;2095       27.2026 (0.44)      12772           1
test___digital_multi_channel_writer___write_waveform_lines[library_init_kwargs-8-100-2]           36.9000 (2.62)        211.6000 (1.33)     40.3585 (2.48)      9.0254 (1.49)     38.3000 (2.61)     0.9000 (2.25)     656;2175       24.7779 (0.40)      12854           1
test___digital_multi_channel_writer___write_waveform_port[library_init_kwargs-100]                38.2000 (2.71)        202.8000 (1.28)     42.4958 (2.61)      9.6598 (1.60)     39.9000 (2.71)     0.9000 (2.25)     842;2501       23.5317 (0.38)      12501           1
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Legend:
  Outliers: 1 Standard Deviation from Mean; 1.5 IQR (InterQuartile Range) from 1st Quartile and 3rd Quartile.
  OPS: Operations Per Second, computed as 1 / Mean
====================================================================================== 38 passed, 38 deselected in 17.26s =======================================================================================

@bkeryan
Copy link
Collaborator

bkeryan commented Oct 10, 2025

Why should this Pull Request be merged?
AB#3330619

@EnYi-ni This is a GitHub issue, so you should include something like Fixes #843 or Closes #843 in the PR description. This will make GitHub automatically link to the issue and then close it when the PR is merged. I will edit the PR description this time.

Copy link
Collaborator

@bkeryan bkeryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with suggestions (update changelog)

@zhindes
Copy link
Collaborator

zhindes commented Oct 10, 2025

FYI - you can complete once you address Brad's issues and PR build is happy. Maxx doesn't often review code here, its all good :)

- as per Brad's comment, it affects all read and write functions, thus
  may need to let user know this
@charitylxy charitylxy merged commit 0bb90ce into ni:master Oct 13, 2025
30 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

read methods use task.in_stream.channels_to_read, which is slow

4 participants