ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Linux-AIO/lat_test
Revision: 1.5
Committed: Sun Jul 10 16:33:04 2005 UTC (18 years, 9 months ago) by root
Branch: MAIN
CVS Tags: rel-1_9, rel-1_8, rel-1_71, HEAD
Changes since 1.4: +1 -1 lines
Log Message:
*** empty log message ***

File Contents

# Content
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 "/root/anime/eps/Crest*/*") {
13 my $fh;
14 print "$_\n";
15 open $fh, "<", $_ or die "$_: $!";
16 push @fh, $fh;
17 }
18
19 Linux::AIO::min_parallel 8;
20 $nreqs = 64;
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 aio_read ($fh, $offset, 16*1024, $data, 0, sub {
34 $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 Linux::AIO::poll_wait;
51 my $r;
52 select $r = $sr, undef, undef, undef;
53 $SELECT += time;
54 }
55 Linux::AIO::poll_cb;
56 printf "\r$lat $cnt %.4f %.3f ", $lat / $cnt, $SELECT/(time - $START);
57 }
58