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

📄 semastats.prl

📁 一个用在mips体系结构中的操作系统
💻 PRL
字号:
#!/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. #%semaInfo = ();$inputFile = "cpu.log";$numsemas = -1;$found = 0;$i=0;while ($i<=$#ARGV) {    if ($ARGV[$i] eq "-f") {        $i++;        $inputFile = $ARGV[$i];    } elsif ($ARGV[$i] eq "-l") {        $i++;        $showSema{$ARGV[$i]} = 1;    } elsif ($ARGV[$i] eq "-n") {        $i++;        $numsemas = $ARGV[$i];    } else {        print "usage: semastats [-f file] [-l sema] [-n numsemas]\n";        exit;    }    $i++;}open(LOGFILE, $inputFile);while (<LOGFILE>) {    if (/^SEMASTATS: \s+ start/x) {        undef %semaInfo;        $total = 0;        $found++;            } elsif (/^SEMASTATS:\s+sema\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+/) {        $sema = $1;        $total += $3;        $semaInfo{$sema}{'name'} = $sema;        $semaInfo{$sema}{'nwait'} = $2;        $semaInfo{$sema}{'totwait'} = $3;        $semaInfo{$sema}{'sqwait'} = $4;        $semaInfo{$sema}{'minwait'} = $5;        $semaInfo{$sema}{'maxwait'} = $6;        if (!defined($semaInfo{$sema}{'iname'})) {            $semaInfo{$sema}{'iname'} = "";            $semaInfo{$sema}{'caller'} = "";        }                } elsif (/^SEMAINIT:\s+(\S+)\s+\S+\s+\S+\s+(\S+)\s+(\S+)/) {        $sema = $1;        $semaInfo{$sema}{'iname'} = $2;        $semaInfo{$sema}{'caller'} = $3;        $semaInfo{$sema}{'name'} = $sema;        $semaInfo{$sema}{'nwait'} = 0;        $semaInfo{$sema}{'totwait'} = 0;        $semaInfo{$sema}{'sqwait'} = 0;        $semaInfo{$sema}{'minwait'} = 0;        $semaInfo{$sema}{'maxwait'} = 0;    }}close(LOGFILE);if (!$found) {    print "FATAL ERROR: no semastats stuff found, you must not have source'd sema_stats.tcl\n";}$num = 0;    printHeader();foreach $sema (sort bywait (keys %semaInfo)) {    if ($semaInfo{$sema}{'nwait'} == 0) {        next;    }    $num++;        if (($numsemas != -1) && defined(%showSema)) {        if (($num > $numsemas) && !defined($showSema{$sema})) {            next;        }    } elsif (($numsemas != -1) && ($num > $numsemas)) {        next;            } elsif (defined(%showSema) && !defined($showSema{$sema})) {        next;    }    printSema($semaInfo{$sema}, $num, "");}sub bywait {    $semaInfo{$b}{'totwait'} <=> $semaInfo{$a}{'totwait'};}sub printHeader {    printf "%-4s %-15s %6s %7s %-15s %-10s %-15s\n",    "num", "sema",    "% of sema", "count", "wait", "Name", "Init";    print "-----------------------------------------------------------------------------\n";}sub printSema {    my($bucket, $num, $prefix) = @_;    printf "%-4s %-15s %6.2f %7d %15.2f %-10s %-15s\n",    $num,    "$bucket->{'name'}", (100.0 * $bucket->{'totwait'}) / $total, $bucket->{'nwait'},    $bucket->{'totwait'} / $bucket->{'nwait'}, $bucket->{'iname'}, $bucket->{'caller'};}

⌨️ 快捷键说明

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