ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-AIO/lat_test
Revision: 1.4
Committed: Sun Jul 10 15:00:38 2005 UTC (18 years, 10 months ago) by root
Branch: MAIN
Changes since 1.3: +6 -5 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 root 1.4 for(File::Glob::glob "/root/anime/eps/Crest*/*") {
13 root 1.1 my $fh;
14     print "$_\n";
15     open $fh, "<", $_ or die "$_: $!";
16     push @fh, $fh;
17     }
18    
19 root 1.4 Linux::AIO::min_parallel 2;
20     $nreqs = 64;
21 root 1.1
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.4 aio_read ($fh, $offset, 16*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 root 1.4 Linux::AIO::poll_wait;
51 root 1.1 my $r;
52     select $r = $sr, undef, undef, undef;
53     $SELECT += time;
54     }
55     Linux::AIO::poll_cb;
56 root 1.4 printf "\r$lat $cnt %.4f %.3f ", $lat / $cnt, $SELECT/(time - $START);
57 root 1.1 }
58