ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-AIO/lat_test
Revision: 1.2
Committed: Tue Aug 14 23:25:39 2001 UTC (22 years, 9 months ago) by root
Branch: MAIN
Changes since 1.1: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #!/usr/bin/perl
2    
3     # calculcate average latency
4    
5     use Linux::AIO;
6     use Time::HiRes qw(time);
7     use File::Glob qw();
8    
9     my $START = time;
10     my $SELECT;
11    
12     for(File::Glob::glob "/fs/anime/eps/*Basara/*") {
13     my $fh;
14     print "$_\n";
15     open $fh, "<", $_ or die "$_: $!";
16     push @fh, $fh;
17     }
18    
19 root 1.2 Linux::AIO::min_parallel 8;
20 root 1.1 $nreqs = 50;
21    
22     my $lat;
23     my $cnt = 1e-36;
24    
25     $|=1;
26    
27     sub gen_request {
28     my $fh = @fh[rand @fh];
29     my $offset = int rand 75000000;
30     my $data;
31     my $start = time;
32     #print "starting new req ($fh, $offset)\n";
33 root 1.2 aio_read($fh, $offset, 256*1024, $data, 0, sub {
34 root 1.1 $start = time - $start;
35     $lat += $start;
36     $cnt++;
37     #print "io returned ($fh, $offset, $start)\n";
38     });
39     }
40    
41     gen_request while (Linux::AIO::nreqs < $nreqs);
42    
43     my $sr = ""; vec($sr, Linux::AIO::poll_fileno, 1) = 1;
44    
45     while(1) {
46     if (Linux::AIO::nreqs < $nreqs) {
47     gen_request;
48     } else {
49     $SELECT -= time;
50     my $r;
51     select $r = $sr, undef, undef, undef;
52     $SELECT += time;
53     }
54     Linux::AIO::poll_cb;
55     printf "\r$lat $cnt %.2f %.3f ", $lat / $cnt, $SELECT/(time - $START);
56     }
57