I open and close the handles continuously in my test because that is how my application behaves. While running the application the user can plug and unplug the USB devices which have to be reflected in my application immediately( there is a visual indicator as to how many USB devices are plugged in). So I open new handles to the USB devices once every second.<br>
<br>My target platform is the OLPC(it is a small $100 Linux based laptop). In my application a Motion sensor can be connected to the computer through the USB device and when it is connected I read from the sensor every 5ms so that I can detect any sort of movement across the motion sensor. The OLPC in itself is very slow and that coupled with my requirement on the USB driver has led the motion sensor to be very sluggish in its response.<br>
<br>Thanks<br>Shivaprasad<br><br><div class="gmail_quote">On Wed, Apr 29, 2009 at 5:32 PM, Charles Lepple <span dir="ltr">&lt;clepple@ghz.cc&gt;</span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Apr 29, 2009, at 1:50 AM, shivaprasad javali wrote:<br>
<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
I did a small test of Opening the handles to my USB device , reading from them and closing the handles 1000 times in a loop to see how long it takes. The test took around 36-37 seconds on Linux where as it took around 12-13 seconds on the Mac. On the mac I am using the IOKit framework that mac provides for the driver. As far as I can tell I am using the libhid correctly and making no unnecessary calls which would slow down the driver.<br>

</blockquote>
<br></div>
I would consider opening and closing the handles in the loop to be unnecessary when benchmarking. A typical application only needs to open the interface one at the beginning.<br>
<br>
You should also be able to run the test using libhid on OS X, which removes variables related to the platform.<br>
<br>
libhid is implemented on top of libusb, which calls IOKit on OS X. That&#39;s an extra two layers of indirection right there - if you want direct access to either IOKit or the Linux hiddev API, it shouldn&#39;t be too hard to add to libhid.<br>

<br>
Also, the HID protocol is not necessarily high-performance to begin with, and you are limited by the number of USB transactions that you can initiate per second.<br>
</blockquote></div><br>