Update contrib.
2 # Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies).
4 # This component and the accompanying materials are made available
5 # under the terms of the License "Eclipse Public License v1.0"
6 # which accompanies this distribution, and is available
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html".
9 # Initial Contributors:
10 # Nokia Corporation - initial contribution.
15 # USBperformance - write file to / read file from
16 # a USB Mass Storage device,
17 # measure the time taken,
18 # and display the data rate achieved.
27 pod2usage("$0: Specify at least a target drive.\n") if (@ARGV < 1);
32 my $local_file = "gobble.dat";
34 my %opts = ('help' => \$help,
36 'read=s' => \$reading);
38 GetOptions(%opts) || pod2usage(2);
39 pod2usage(-exitval => 1, -verbose => 2) if $help;
41 $size = 1 if $size < 1;
43 my $drive = $ARGV[@ARGV - 1];
45 $drive .= "/" unless ($drive =~ m/\/$/);
46 print "Remote drive: " . $drive . "\n";
48 my $remote_file = "$drive$local_file";
50 # If set to nonzero $¦ forces a flush right away and after every write or print
51 # on the currently selected output channel.
56 print "Writing a $size MB file to the remote directory.\n";
57 print "Creating source file \"$local_file\"...\n";
59 print "Writing target file \"$remote_file\"...\n";
60 my $write_time = writefile();
61 print "File write took $write_time seconds.\n";
62 printf "That's about %.2f MB/s.\n", ($size / $write_time);
66 print "Reading file from a remote directory.\n";
67 -e $remote_file or die "Remote file \"$remote_file\" doesn't seem to exist";
68 -z $remote_file and die "Remote file \"$remote_file\" seems to be empty";
69 my $size_bytes = -s $remote_file;
70 $size = $size_bytes / 1024 / 1024;
71 print "Reading source file \"$remote_file\" ($size_bytes bytes = $size MB)...\n";
72 my $read_time = readfile();
73 print "File read took $read_time seconds.\n";
74 printf "That's about %.2f MB/s.\n", ($size / $read_time);
84 move($local_file, $remote_file);
85 return (time() - $start);
91 move($remote_file, $local_file);
92 return (time() - $start);
97 open FILE, ">$local_file " or die $!;
98 my $realsize = ($size * 1024 * 1024) / 40;
100 while ($i++ < $realsize)
103 print FILE '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcd' or die $!;
108 ######################################################################
114 usbperformance.pl - Create a large file and write it to a Mass Storage device, or
119 Usage: usbperformance.pl [options] <USB drive>
121 <USB drive>: The path to / drive letter of the USB Mass Storage device.
133 The size of the file to be created to measure the speed connection.
135 Size is expected in MB. Default value if no option given is 400 MB.
142 Default value if no option given is 0 (write).
144 Ensure the card/device has been ejected and thus flushed before you do the
145 reading test after the writing case, otherwise the content will be cached by
146 the local OS and the time measured won't be realistic.
148 'Write' will leave the transferred file on the remote disk, but 'Read' will
149 delete it (moving it to the local PC). So a practical test order is:
151 'Write' test, then disconnect/re-connect USB drive, then 'Read' test.
153 This sequence will start and finish with an empty USB disk.
159 This is a simple utility to create a file on a mass storage unit and measure
160 the performance in MB / seconds of the USB connection.
162 =head2 Test Case Specification
164 TestCaseID: PBASE-PREQ709-0045-Performance
166 TestCaseDesc: Test Mass Storage performance on different platforms
167 (Windows 2000/XP/ME, MacOS) (Manual test)
171 Build a ROM with usbmsapp.exe on it. Connect the board to the PC with an USB
172 cable. Execute usbmsapp.exe on the device to map the mass storage unit (MMC/SD
173 card) onto the PC. Execute this script on the PC, and make sure the card has
174 free space for the file that is going to be created. The default size is 400
179 Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.