HidLibrary
HidLibrary copied to clipboard
Performance problem
Hi,
I'm having a bit of a problem with the performance. I am receiving a lot of data and when I do that my cpu is at 100%.
I ran the Visual Studio performance profiler and it says that 90% of the load come from here:
public HidDeviceData Read(int timeout)
if (IsConnected)
And then 80% from here:
NativeMethods.SetupDiGetDeviceRegistryProperty(deviceInfoSet,
ref devinfoData,
NativeMethods.SPDRP_DEVICEDESC,
ref type,
descriptionBuffer,
descriptionBuffer.Length,
ref requiredSize);
It seems like it is doing a lot of stuff while trying to find out if the device is still connected? Is it necessary to do all of that before every read?
Or did I missunderstand something?
Not really sure. I wrote this almost a decade ago for a project so I can't remember why it was setup that way.
I Had the same issue, plase take a look at my solution here: https://github.com/mikeobrien/HidLibrary/issues/11
Please see my solution too: https://github.com/mikeobrien/HidLibrary/issues/11#issuecomment-170944469
I recently changed my project from another Hid library towards the HidLibrary because of issues in unit testing that were not fixed. It was not too complicated to migrate the project and it's up and running right now. The first tests showed a stable communication.
The only thing I'm struggeling is that writing many data over Hid reports is very slow. A google search brought me to this issue and I assume that this also is the problem in my case.
As far as I see there is no way of fixing this performance issue with the official version from the NuGet server, right? It seems that the only solutions proposed above are implemented on forks or copies of the HidLibrary.
Are there any plans to add a possibility to "ignore" the IsConnected check?
The HidFastReadDevice class essentially replicates the HidDevice class but skips the IsConnected check. This is already part of the library, so I feel like we could close this issue if that solves your problem.
I've seen that, but the HidFastReadDevice only provides fast read functions (as the name also implies). What I would need is a HidFastWriteDevice that provides fast write operations.