Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 390
  • Last Modified:

[Embedded Linux]: Performance measurement for USB device


I have a device connected to Ubuntu machine via USB port. Device is using embedded Linux as operating system and I can change the internals of device. I want to measure performance of the device on following terms:

Speed of transaction(s) over USB,
Power consumption of the device,
Time taken by device (specifically kernel) to loopback data

Can anyone please let me know what tool set I can use to measure performance of my device connected via USB port?


1 Solution
time dd if=/dev/zero of=/dev/sdb  bs=64k   (substitute device name of the USB and cTRL-C after a minute or so).  This will give you write speed.
For power consumption, you need to purchase an ammeter and put it inline.  Maybe $20.00 at a radio shack.

Time for loopback??  N/A on USB.
First you need to mount usb, or it may be done automatically for you.

Open shell.

Go to the folder where your usb is mounted.

Issue the following command
time dd=/dev/zero of=file bs=1M count=10

Open in new window

This command transfers precisely 10MB size of file (size on disk varies).  You will also see the time it took, OS time, etc.

With this you can make your calculations.
Both mine and farzanjs techniques work, and bench different aspects.    Mine does raw I/O which is a pure write test.   Farzanj's test will do filesystem I/O.  This will run slower, as there will be a read component, and it will vary depending on file system parameters.

Real-world, both are valid, and bench different aspects of performance.  You should run both.
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

use the lsusb -v and it will mention the power consumption by the devices and mount sys file system and run the utility usbmon which will help to analyze the speed of transfer manually packetwise.
finegraded profiles can be achieved with linux kernel Kprobes. Also the linux kernel has many profiling options, see your kernel documentation.
yogithiteAuthor Commented:

Can you please let me know any examples for creating finegraded profiles?

Also, if I want to do speed measurements then what are the methods I can look out for? Like speed during mass storage transfer etc.

You have two options: black box measurement, or internal measurement.
The first one, you do not touch the measured device and use a good realtime environment with specifics programs to test the response. For example, take the absolute time (with us precision), send a request, wait for response and take the new absolute time.
Another option is use an oscilloscope - this way you can test the right time without the sending/receiving overhead of your testing machine.
With the internal measurement, you MUST "instrument" your kernel/device driver. There are none example I know of, but look carefully on google or in some book for "oprofile".
For power consumption, you need a wattmeter or an amperometer to connect on your power supply. Better use a wattmeter, because power consumption varies with device operations.
Maximum power consumption can also be estimated by the single chip datasheets.

Featured Post

Who's Defending Your Organization from Threats?

Protecting against advanced threats requires an IT dream team – a well-oiled machine of people and solutions working together to defend your organization. Download our resource kit today to learn more about the tools you need to build you IT Dream Team!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now