Re: measuring usb transfer throughput

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Apr 04, 2006 at 04:13:59PM +0100, Bahadir Balban wrote:
> Hi,
> 
> I am trying to measure usb transfer throughput by timing file read
> operations from a usb flashdisk into main memory. The results seems to
> be imprecise and I suspect this is due to filesystem caching. How
> could I prohibit filesystem caching in the kernel?

I recently did the same thing.  I used g_ether to do my benchmarking
and ttcp.  You can use sync to help with the caching issue
like this:
#mount /dev/mmc /mnt
dd if=/dev/zero  of=/mnt/4MB_file count=4096
#umount /dev/mmc 
sync

I put that in a script



also you can use the open system call with O_SYNC

like this:

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

char buf[4096*1024];

int main()
{
        int fd, i;

        fd = open("/mnt/sync_file", O_CREAT | O_SYNC | O_WRONLY);
        //for(i=0;i<1000;i++) {
                write(fd, buf, 4096*1024);
//      }

}




from man page:
  O_SYNC The file is opened for  synchronous  I/O.  Any  writes  on  the
              resulting  file descriptor will block the calling process until
              the data has been physically written to  the  underlying  hard-
              ware.  See RESTRICTIONS below, though.



you can also try using rawdevice
  http://www.linux.com/howtos/SCSI-2.4-HOWTO/rawdev.shtml

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux