Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

Slow python execution of nidaq functions

I need to run a measurement using both matlab and python. Since I have a custom use case I used the c API to write a dll that creates a task and then per request starts the task, reads the data and stops the task. The block I care about performance-wise is the start-read-stop part. This (for my typical parameters of rate, channel & sample num) takes ~100 ms running it from full C++ code or from the matlab interface. In python, for some reason, it takes more than 200 ms. The times I mention here are just the execution as reported in the I/O trace log. 


In the attached traces:

First block create to clear is C++.

Second is matlab.

Third is python.


I just can't understand why the same code, running the same function from NIDAQmx c api takes more time if it happened to be called from python. I'd really appriciate it if anyone has any idea why this happens and how I can get around that.

0 Kudos
Message 1 of 3

Because Python is an interpreter language while C is pre-compiled.

Python vs C: Top 12 Differences You Must Know

Message 2 of 3

That would explain the overall run time difference. In my case there’s some function (python/ matlab/ C++) calling a dll in C++ which calls NIDAQmx dll function. Why does the NIDAQmx performance depend on the caller? 

0 Kudos
Message 3 of 3