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

📄 convert-parv.pl

📁 目前最精确的磁盘模拟器的第3版
💻 PL
📖 第 1 页 / 共 3 页
字号:
#!/usr/bin/perl# DiskSim Storage Subsystem Simulation Environment (Version 3.0)# Revision Authors: John Bucy, Greg Ganger# Contributors: John Griffin, Jiri Schindler, Steve Schlosser## Copyright (c) of Carnegie Mellon University, 2001, 2002, 2003.## This software is being provided by the copyright holders under the# following license. By obtaining, using and/or copying this software,# you agree that you have read, understood, and will comply with the# following terms and conditions:## Permission to reproduce, use, and prepare derivative works of this# software is granted provided the copyright and "No Warranty" statements# are included with all reproductions and derivative works and associated# documentation. This software may also be redistributed without charge# provided that the copyright and "No Warranty" statements are included# in all redistributions.## NO WARRANTY. THIS SOFTWARE IS FURNISHED ON AN "AS IS" BASIS.# CARNEGIE MELLON UNIVERSITY MAKES NO WARRANTIES OF ANY KIND, EITHER# EXPRESSED OR IMPLIED AS TO THE MATTER INCLUDING, BUT NOT LIMITED# TO: WARRANTY OF FITNESS FOR PURPOSE OR MERCHANTABILITY, EXCLUSIVITY# OF RESULTS OR RESULTS OBTAINED FROM USE OF THIS SOFTWARE. CARNEGIE# MELLON UNIVERSITY DOES NOT MAKE ANY WARRANTY OF ANY KIND WITH RESPECT# TO FREEDOM FROM PATENT, TRADEMARK, OR COPYRIGHT INFRINGEMENT.# COPYRIGHT HOLDERS WILL BEAR NO LIABILITY FOR ANY USE OF THIS SOFTWARE# OR DOCUMENTATION.# convert disksim v2 parv files to v3 format# provide such a file on STDIN; new file written to STDOUT# $_[0] is the bus list, $_[1] is the controller list, # $_[2] is the bus to start with# $_[3] is a list of things we've already looked at # $_[4] is the depth for indentingsub outputBusTopo {    my $c = 0;    for $i (1 .. $_[4]) { print " "; }    print("disksim_bus $_[2] [ \n");    $_[2] =~ /bus([0-9]+)/;#    print STDERR "busnum $1\n";    $aref = $_[0]->[$1];    foreach $child (@$aref) {	if($c) {	    print ",\n";	}	$vref = $_[3];	foreach $v (@$vref) { 	    if($v eq $child) { #		print STDERR "avoiding visited thing: $child\n"; 		$bad = 1; 		last;	    } 	    else { #		print STDERR "visited $v\n"; 		$bad = 0; 	    }	}	push(@$vref, $child);	if($bad != 1) {#	    print STDERR "buschild $child\n";	    if($child =~ /ctlr.*/) {		outputCtlrTopo($_[0], $_[1], $child, $_[3], $_[4]+5);		$c++;	    }	    else {		$child =~ /(mems2|disk|sd)(.*)/;	        for $i (1 .. ($_[4] + 5)) { print " "; }		$devtype = $1;		$devtype =~ s/sd/simpledisk/;		$devtype = "disksim_$devtype";		print "$devtype $child []";		$c++;	    }	}    }    print "\n";    for $i (1 .. $_[4] + 5) { print " "; }    print "# end of $_[2]\n";    for $i (1 .. $_[4]) { print " "; }    print "]"; }sub outputCtlrTopo {    for $i (1 .. $_[4]) { print " "; }    print("disksim_ctlr $_[2] [ \n");    $_[2] =~ /ctlr([0-9]+)/;#    print STDERR "ctlrnum $1\n";    $aref = $_[1]->[$1];    my $c = 0;    foreach $child (@$aref) {	if($c) {	    print ",\n";	}	$vref = $_[3];	foreach $v (@$vref) { 	    if($v eq $child) { #		print STDERR "avoiding visited thing: $child\n"; 		$bad = 1; 		last;	    } 	    else { #		print STDERR "visited $v\n"; 		$bad = 0; 	    }	}	push(@$vref, $child);	if($bad != 1) {#	    print STDERR "ctlrchild $child\n";		    outputBusTopo($_[0], $_[1], $child, $_[3], $_[4] + 5);	    $c++;	}    }    print "\n";    for $i (1 .. $_[4] + 5) { print " "; }    print "# end of $_[2]\n";    for $i (1 .. $_[4]) { print " "; }    print("]");}sub error {    print STDERR "*** error: $_[0]\n";    exit(1);}# clean out empty lines, etc.$linenum = 1;while (<STDIN>) {    $line = $_;    if(($line =~ /^\s*$/) || ($line eq "") || ($line eq undef)) { }    else {        # mash whitespace together	$line =~ s/\s+/ /g;	# eat trailing whitespace	$line =~ s/\s*$//;	$line =~ s/Print stats(.*):/Print stats = /;	push(@lines, $line);	push(@linenums, $linenum);#	print("$line\n");    }    $linenum++;}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Byte Order.*: (Big|Little)/) {    print("disksim_global Global { \n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Init Seed: ([0-9]+|TIME)/) {    $line =~ s/:/ =/;    print("   $line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Real Seed: ([0-9]+|TIME)/) {    $line =~ s/:/ =/;    print("   $line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Statistic warm-up period: ([0-9]+(\.[0-9]+)?).*/) {    $line =~ s/:/ =/;    print("   # $line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Checkpoint to ([^\s]+) every: ([0-9]+(\.[0-9]+)?) (seconds|I\/Os)/) {    $checkpointfile = $1;    $checkpointfreq = $2;    $checkpointunit = $3;}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Stat \(dist\) definition file: ([^\s]+)/) {    $statdefs = $1;    print("   Stat definition file = $statdefs\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Output file for.*/) {    $line =~ s/:/ =/;    print("   # $line\n}\n\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /I\/O Subsystem Input.*/) {}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /-*/) {}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /PRINTED I\/O SUBSYSTEM.*/) {    print("disksim_stats Stats {\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver size stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("iodriver stats = disksim_iodriver_stats {\n$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver locality stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver blocking stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver interference stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver queue stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver crit stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver idle stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver intarr stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver streak stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver stamp stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print driver per-device stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line },\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print bus idle stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("bus stats = disksim_bus_stats {\n$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print bus arbwait stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line },\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller cache stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("ctlr stats = disksim_ctlr_stats {\n$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller size stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller locality stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller blocking stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller interference stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller queue stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller crit stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller idle stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller intarr stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller streak stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller stamp stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print controller per-device stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line },\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device queue stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("device stats = disksim_device_stats {\n$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device crit stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device idle stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device intarr stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device size stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device seek stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device latency stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device xfer stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device acctime stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device interfere stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line,\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}$line = shift(@lines); $linenum = shift(@linenums);if($line =~ /Print device buffer stats\? (0|1)/) {    $line =~ s/\?/ =/;    print("$line },\n");}else {    print STDERR "*** error on line $linenum: $line.\n";    exit(1);}# find the procflow stats$gotprocflowstat = 0;print("process flow stats = disksim_pf_stats {\n");for $c (0 .. ($#lines - 1)) {    if($lines[$c] =~ /PRINTED PROCESS-FLOW STATISTICS/) {       for $d (1..4) {          $lines[$c + $d] =~ s/\?/ = /;	  print("$lines[$c+$d]");	  if($d != 4) { print(","); }	  print("\n");       }       $gotprocflowstat = 1;    }}if(! $gotprocflowstat) {   error("couldn't find process flow statistics specs");}print("}\n");print("} # end of stats block\n\n\n");#

⌨️ 快捷键说明

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