Mac M2 pro libusb read/write performance

I am writing a C program on Mac that calls the libUSB API. However, I found some performance differences between the same programs on MAC x64 and MAC M2 systems. Program on Mac m2 call libusb_control_transfer() function is much slower than programs on Mac x64.

For example, running a program on Mac x64 takes 3 seconds to complete a function, while on Mac m2 it takes 10 seconds. I try to count the number of times a program calls libusb_control_transfer() and the time it takes each time, and finally calculate the average time it takes to call libusb_control_transfer().

The following figure shows the performance of the program on Mac m2.(Unit is us per time)

The following figure shows the performance of the program on Mac x64. (Unit is us per time)

The difference in average time spent calling a function has reached over 10 times.

Is this performance gap caused by the USB driver or the libUSB library?

Thanks.

  • Try the test functions from this snippet and see if the outcome is the same: https://android.googlesource.com/platform/external/libusb/+/HEAD/examples/xusb.c https://cpp.hotexamples.com/examples/-/-/libusb_control_transfer/cpp-libusb_control_transfer-function-examples.html https://github.com/Codingboy/ucuni/blob/master/src/example.c

Add a Comment

Replies

are you sure that the device you are communicating with is enumerating at the same speed on each platform?