- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- PERL - find MAX, MIN
Operating System - Linux
1748198
Members
2570
Online
108759
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-02-2005 09:42 AM
тАО09-02-2005 09:42 AM
PERL - find MAX, MIN
Hi,
I am written a PERL script which calculates the average response time of a system.
Now, I need to find the MAX time and the MIN time from the response times.
Also, I need to find the 10% of the worst calls ( the calls which have taken the maximum times) and also find the maximum and minimum time among the worst 10% calls.
Can anyone please help me.
Thanks,
Rahul
I am written a PERL script which calculates the average response time of a system.
Now, I need to find the MAX time and the MIN time from the response times.
Also, I need to find the 10% of the worst calls ( the calls which have taken the maximum times) and also find the maximum and minimum time among the worst 10% calls.
Can anyone please help me.
Thanks,
Rahul
- Tags:
- Perl
2 REPLIES 2
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-02-2005 11:51 AM
тАО09-02-2005 11:51 AM
Re: PERL - find MAX, MIN
Hi Rahul:
Here's a suggestion.
One method of attack would be to collect your response time samples into a list, array or hash, depending on your processing requirements. Having counted the total samples as you collect them, you can find the 10% (0.1 N) of the samples (N) that represent the worst response times by taking the first 10% of a list of response times sorted in descending order (longest/worst to shortest/best).
Finding a minimum and maximum is simple too.
Assuming that @ary contains your response times:
$min=2**32-1;
$max=0;
for $t (@ary) {$min=$t if $t < $min};
for $t (@ary) {$max=$t if $t > $max};
Regards!
...JRF...
Here's a suggestion.
One method of attack would be to collect your response time samples into a list, array or hash, depending on your processing requirements. Having counted the total samples as you collect them, you can find the 10% (0.1 N) of the samples (N) that represent the worst response times by taking the first 10% of a list of response times sorted in descending order (longest/worst to shortest/best).
Finding a minimum and maximum is simple too.
Assuming that @ary contains your response times:
$min=2**32-1;
$max=0;
for $t (@ary) {$min=$t if $t < $min};
for $t (@ary) {$max=$t if $t > $max};
Regards!
...JRF...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО09-03-2005 04:08 AM
тАО09-03-2005 04:08 AM
Re: PERL - find MAX, MIN
SMOP...
----- First create a sample data file:
# perl -e 'while ($i++<70) {printf "%05d %5f\n", $i, rand}' > x
------ Perl script x.p
$w = 10;
# read times into array keyed by call
while (<>){
($i,$x)=split;
$x{$i}=$x;
}
# create list of calls ordered by time, and count
@o = sort {$x{$a} <=> $x{$b}} keys %x;
$n = scalar @o;
# report result
print "There were $n calls, min time = $x{@o[0]}, max time = $x{@o[$n-1]}\nThe worst $w% calls were:\n";
$w *= $n/100;
$j = int($n - $w);
while ( $j < $n ) {
$i=@o[$j++];
print "$j $i $x{$i}\n";
}
----- sample execute
# perl x.p x
There were 70 calls, min time = 0.002133, max time = 0.990953
The worst 10% calls were:
64 00036 0.933632
65 00030 0.935374
66 00067 0.935947
67 00001 0.956462
68 00019 0.967803
69 00052 0.969352
70 00031 0.990953
Hein.
----- First create a sample data file:
# perl -e 'while ($i++<70) {printf "%05d %5f\n", $i, rand}' > x
------ Perl script x.p
$w = 10;
# read times into array keyed by call
while (<>){
($i,$x)=split;
$x{$i}=$x;
}
# create list of calls ordered by time, and count
@o = sort {$x{$a} <=> $x{$b}} keys %x;
$n = scalar @o;
# report result
print "There were $n calls, min time = $x{@o[0]}, max time = $x{@o[$n-1]}\nThe worst $w% calls were:\n";
$w *= $n/100;
$j = int($n - $w);
while ( $j < $n ) {
$i=@o[$j++];
print "$j $i $x{$i}\n";
}
----- sample execute
# perl x.p x
There were 70 calls, min time = 0.002133, max time = 0.990953
The worst 10% calls were:
64 00036 0.933632
65 00030 0.935374
66 00067 0.935947
67 00001 0.956462
68 00019 0.967803
69 00052 0.969352
70 00031 0.990953
Hein.
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
News and Events
Support
© Copyright 2024 Hewlett Packard Enterprise Development LP