⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mef.pl

📁 Oracle optimizing performance things
💻 PL
字号:
#!/usr/bin/perl

# $Header: /home/cvs/cvm-book1/measurement\040intrusion/mef.pl,v 1.4 2003/03/19 04:38:48 cvm Exp $
# Cary Millsap (cary.millsap@hotsos.com)
# Copyright (c) 2003 by Hotsos Enterprises, Ltd. All rights reserved.

use strict;
use warnings;
use Time::HiRes qw(gettimeofday);

sub fnum($;$$) {
    # return string representation of numeric value in
    # %.${precision}f format with specified separators
    my ($text, $precision, $separator) = @_;
    $precision = 0   unless defined $precision;
    $separator = "," unless defined $separator;
    $text = reverse sprintf "%.${precision}f", $text;
    $text =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1$separator/g;
    return scalar reverse $text;
}

my ($min, $max) = (100, 0);
my $sum = 0;
print "How many iterations? "; my $n = <>;
print "Enter 'y' if you want to see all the data: "; my $all = <>;
for (1 .. $n) {
    my ($s0, $m0) = gettimeofday;
    my ($s1, $m1) = gettimeofday;
    my $sec = ($s1 - $s0) + ($m1 - $m0)/1E6;
    printf "%0.6f\n", $sec if $all =~ /y/i;
    $min = $sec if $sec < $min;
    $max = $sec if $sec > $max;
    $sum += $sec;
}
printf "gettimeofday latency for %s samples\n", fnum($n);
printf "\t%0.6f    seconds minimum\n", $min;
printf "\t%0.6f    seconds maximum\n", $max;
printf "\t%0.9f seconds average\n", $sum/$n;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -