os/kernelhwsrv/kerneltest/f32test/smassstorage/scripts/usbperformance_multifile.pl
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_multifile - write 100 files to / read them from
16 # a USB Mass Storage device,
17 # measure the time taken,
18 # and display the data rate achieved.
27 pod2usage("$0: Specify a target drive.\n") if (@ARGV < 1);
30 my $size = 4; # size of a single file in MB
31 my $files = 100; # total number of files
34 my %opts = ('help' => \$help,
35 'read=s' => \$reading);
37 GetOptions(%opts) || pod2usage(2);
38 pod2usage(-exitval => 1, -verbose => 2) if $help;
40 my $drive = $ARGV[@ARGV - 1];
42 $drive .= "/" unless ($drive =~ m/\/$/);
43 print "Remote drive: " . $drive . "\n";
45 # If set to nonzero $¦ forces a flush right away and after every write or print
46 # on the currently selected output channel.
51 print "Writing $files $size-MB files to the remote directory.\n";
52 print "Creating source files...\n";
54 print "Writing target files...\n";
55 my $write_time = write_files();
56 print "File write took $write_time seconds.\n";
57 printf "That's about %.2f MB/s.\n", ($size * $files / $write_time);
61 print "Reading files back from remote directory.\n";
62 print "Reading source files...\n";
63 my $read_time = read_files();
64 print "File read took $read_time seconds.\n";
65 printf "That's about %.2f MB/s.\n", ($size * $files / $read_time);
75 for (my $i = 1; $i <= $files; $i++)
77 my $filename = "usbfile" . $i . ".dat";
78 print "Writig $filename\r";
79 move($filename, "$drive" . $filename);
82 return (time() - $start);
88 for (my $i = 1; $i <= $files; $i++)
90 my $filename = "usbfile" . $i . ".dat";
91 print "Reading $filename\r";
92 move("$drive" . $filename, $filename);
95 return (time() - $start);
100 for (my $i = 1; $i <= $files; $i++)
102 my $filename = "usbfile" . $i . ".dat";
103 print "Creating file $filename\r";
104 open FILE, ">$filename " or die $!;
105 my $fills = ($size * 1024 * 1024) / 64;
107 while ($j++ < $fills)
109 # Add 64 characters at a time
110 print FILE '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz?!' or die $!;
119 for (my $i = 1; $i <= $files; $i++)
121 my $filename = "usbfile" . $i . ".dat";
126 ######################################################################
132 usbperformance_multifile.pl - Create 100 files and write them to a Mass Storage device or
137 Usage: usbperformance_multifile.pl [options] <USB drive>
139 <USB drive>: The path to / drive letter of the USB Mass Storage device.
154 Default value if no option given is 0 (write).
156 Ensure the card/device has been ejected and thus flushed before you do the
157 reading test after the writing case, otherwise the content will be cached by
158 the local OS and the time measured won't be realistic.
160 'Write' will leave the transferred files on the remote disk, but 'Read' will
161 delete them (moving them to the local PC). So a practical test order is:
163 'Write' test, then disconnect/re-connect USB drive, then 'Read' test.
165 This sequence will start and finish with an empty USB disk.
171 This is a simple utility to create a file on a mass storage unit and measure
172 the performance in MB / seconds of the USB connection.
174 =head2 Test Case Specification
176 TestCaseID: PBASE-PREQ709-0045-Performance
178 TestCaseDesc: Test Mass Storage performance on different platforms
179 (Windows 2000/XP/ME, MacOS) (Manual test)
183 Build a ROM with usbmsapp.exe on it. Connect the board to the PC with an USB
184 cable. Execute usbmsapp.exe on the device to map the mass storage unit (MMC/SD
185 card) onto the PC. Execute this script on the PC, and make sure the card has
186 free space for the file that is going to be created. The default size is 400
191 Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.