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

📄 syncstats

📁 一个用在mips体系结构中的操作系统
💻
字号:
#!/usr/local/bin/perl5 -w## Copyright (C) 1996-1998 by the Board of Trustees#    of Leland Stanford Junior University.# # This file is part of the SimOS distribution. # See LICENSE file for terms of the license. #%lockInfo = ();$inputFile = "cpu.log";$showRA = 0;$numlocks = -1;$found = 0;$i=0;while ($i<=$#ARGV) {    if ($ARGV[$i] eq "-f") {        $i++;        $inputFile = $ARGV[$i];    } elsif ($ARGV[$i] eq "-ra") {        $showRA = 1;    } elsif ($ARGV[$i] eq "-l") {        $i++;        $showLock{$ARGV[$i]} = 1;    } elsif ($ARGV[$i] eq "-n") {        $i++;        $numlocks = $ARGV[$i];    } else {        print "usage: syncstats [-f file] [-ra] [-l lock] [-n numlocks]\n";        exit;    }    $i++;}open(LOGFILE, $inputFile);while (<LOGFILE>) {    if (/^SYNCSTATS: \s+ start/x) {        undef %lockInfo;        $total = 0;        $found++;            } elsif (/^SYNCSTATS: \s+ lock \s+ (\S+) \s+             n             \s+ (\d+) \s+             sumX          \s+ (\S+) \s+             sumY          \s+  \S+  \s+             sumXX         \s+ (\S+) \s+             sumYY         \s+  \S+  \s+             sumXY         \s+  \S+  \s+             minX          \s+ (\S+) \s+             maxX          \s+ (\S+) \s+             minY          \s+  \S+  \s+             maxY          \s+  \S+  \s+             n             \s+ (\d+) \s+             sumX          \s+ (\S+) \s+             sumY          \s+  \S+  \s+             sumXX         \s+ (\S+) \s+             sumYY         \s+  \S+  \s+             sumXY         \s+  \S+  \s+             minX          \s+ (\S+) \s+             maxX          \s+ (\S+) \s+             minY          \s+  \S+  \s+             maxY          \s+  \S+ /x) {        ($lock, $ra) = split(',', $1);        if (!defined($lockInfo{$lock})) {            $lockInfo{$lock}{'total'}{'name'} = "$lock";            $lockInfo{$lock}{'total'}{'nwait'} = 0;            $lockInfo{$lock}{'total'}{'totwait'} = 0;            $lockInfo{$lock}{'total'}{'sqwait'} = 0;            $lockInfo{$lock}{'total'}{'minwait'} = 0;            $lockInfo{$lock}{'total'}{'maxwait'} = 0;            $lockInfo{$lock}{'total'}{'nheld'} = 0;            $lockInfo{$lock}{'total'}{'totheld'} = 0;            $lockInfo{$lock}{'total'}{'sqheld'} = 0;            $lockInfo{$lock}{'total'}{'minheld'} = 0;            $lockInfo{$lock}{'total'}{'maxheld'} = 0;        }        $total += $3;                $lockInfo{$lock}{$ra}{'name'} = "$ra";        $lockInfo{$lock}{$ra}{'nwait'} = $2;        $lockInfo{$lock}{$ra}{'totwait'} = $3;        $lockInfo{$lock}{$ra}{'sqwait'} = $4;        $lockInfo{$lock}{$ra}{'minwait'} = $5;        $lockInfo{$lock}{$ra}{'maxwait'} = $6;        $lockInfo{$lock}{$ra}{'nheld'} = $7;        $lockInfo{$lock}{$ra}{'totheld'} = $8;        $lockInfo{$lock}{$ra}{'sqheld'} = $9;        $lockInfo{$lock}{$ra}{'minheld'} = $10;        $lockInfo{$lock}{$ra}{'maxheld'} = $11;            $lockInfo{$lock}{'total'}{'nwait'} += $2;        $lockInfo{$lock}{'total'}{'totwait'} += $3;        $lockInfo{$lock}{'total'}{'sqwait'} += $4;        $lockInfo{$lock}{'total'}{'minwait'} += $5;        $lockInfo{$lock}{'total'}{'maxwait'} += $6;        $lockInfo{$lock}{'total'}{'nheld'} += $7;        $lockInfo{$lock}{'total'}{'totheld'} += $8;        $lockInfo{$lock}{'total'}{'sqheld'} += $9;        $lockInfo{$lock}{'total'}{'minheld'} += $10;        $lockInfo{$lock}{'total'}{'maxheld'} += $11;    }}close(LOGFILE);if (!$found) {    print "FATAL ERROR: no syncstats stuff found, you must not have source'd sync_stats.tcl\n";}$num = 0;    printHeader();foreach $lock (sort bywait (keys %lockInfo)) {    $num++;    if (($numlocks != -1) && defined(%showLock)) {        if (($num > $numlocks) && !defined($showLock{$lock})) {            next;        }    } elsif (($numlocks != -1) && ($num > $numlocks)) {        next;            } elsif (defined(%showLock) && !defined($showLock{$lock})) {        next;    }    printLock($lockInfo{$lock}{'total'}, $num, "");    if ($showRA) {        foreach $ra (sort byheld (keys %{$lockInfo{$lock}})) {            if ($ra ne "total") {                printLock($lockInfo{$lock}{$ra}, "", "  ");            }        }    }}sub bywait {    $lockInfo{$b}{'total'}{'totwait'} <=> $lockInfo{$a}{'total'}{'totwait'};}sub byheld {    $lockInfo{$lock}{$b}{'totheld'} <=> $lockInfo{$lock}{$a}{'totheld'};}sub printHeader {    printf "%-4s %-25s %10s  %10s  %10s  %10s\n",    "num",    ($showRA) ?  "lock / ra" : "lock name",    "% of sync", "num", "wait", "held";    print "-----------------------------------------------------------------------------\n";}sub printLock {    my($bucket, $num, $prefix) = @_;    printf "%-4s %-25s %10.2f  %10d  %10.2f  %10.2f\n",    $num,    "$prefix$bucket->{'name'}",    (100.0 * $bucket->{'totwait'}) / $total,    $bucket->{'nwait'},    $bucket->{'totwait'} / $bucket->{'nwait'},    $bucket->{'totheld'} / $bucket->{'nheld'};}

⌨️ 快捷键说明

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