Lines Matching +full:sub +full:- +full:system

1 #!/usr/bin/perl -w
13 # UnixBench - Release 5.1.3, based on:
14 # The BYTE UNIX Benchmarks - Release 3
33 # 3/89 - Ben Smith - BYTE: globalized many variables, modernized syntax
34 # 5/89 - commented and modernized. Removed workload items till they
36 # 11/14/89 - Made modifications to reflect new version of fstime
38 # 10/22/90 - Many tests have been flipped so that they run for
40 # 4/3/91 - Cleaned up and debugged several test parameters - Ben
41 # 4/9/91 - Added structure for creating index and determing flavor of UNIX
42 # 4/26/91 - Made changes and corrections suggested by Tin Le of Sony
43 # 5/15/91 - Removed db from distribution
46 # 12/95 - Massive changes for portability, speed, and more meaningful index
49 # 1997.08.24 DCN Modified "system", replaced double with
50 # whetstone-double in "index"
56 # 2007.09.26 IS Huge rewrite -- see release notes in README.
71 # particularly depending on whether UTF-8 is used. So we always set
109 'system' => { 'name' => "System Benchmarks", 'maxCopies' => 0 },
112 'misc' => { 'name' => "Non-Index Benchmarks", 'maxCopies' => 0 },
117 "arithoh", "short", "int", "long", "float", "double", "whetstone-double"
121 "fstime-w", "fstime-r", "fstime",
122 "fsbuffer-w", "fsbuffer-r", "fsbuffer",
123 "fsdisk-w", "fsdisk-r", "fsdisk"
131 my $system = [
136 "dhry2reg", "whetstone-double", @$oldsystem, "shell1", "shell8"
140 "2d-rects", "2d-ellipse", "2d-aashapes", "2d-text", "2d-blit",
141 "2d-window", "ubgears"
149 "whetstone-double" => undef,
155 "fstime-w" => undef,
156 "fstime-r" => undef,
158 "fsbuffer-w" => undef,
159 "fsbuffer-r" => undef,
161 "fsdisk-w" => undef,
162 "fsdisk-r" => undef,
179 "2d-rects" => undef,
180 "2d-lines" => undef,
181 "2d-circle" => undef,
182 "2d-ellipse" => undef,
183 "2d-shapes" => undef,
184 "2d-aashapes" => undef,
185 "2d-polys" => undef,
186 "2d-text" => undef,
187 "2d-blit" => undef,
188 "2d-window" => undef,
196 "whets" => [ "whetstone-double" ],
197 "whetstone" => [ "whetstone-double" ],
200 "speed" => [ @$arithmetic, @$system ],
202 "system" => $system,
223 "stdout" => 1, # Non-0 to keep stdout.
233 ## System Benchmarks ##
238 "cat" => 'system',
242 "whetstone-double" => {
243 "logmsg" => "Double-Precision Whetstone",
244 "cat" => 'system',
248 "logmsg" => "System Call Overhead",
249 "cat" => 'system',
254 "logmsg" => "Pipe-based Context Switching",
255 "cat" => 'system',
261 "cat" => 'system',
267 "cat" => 'system',
272 "cat" => 'system',
275 "fstime-w" => {
277 "cat" => 'system',
279 "options" => "-w -t 30 -d \"${TMPDIR}\" -b 1024 -m 2000",
281 "fstime-r" => {
283 "cat" => 'system',
285 "options" => "-r -t 30 -d \"${TMPDIR}\" -b 1024 -m 2000",
289 "cat" => 'system',
291 "options" => "-c -t 30 -d \"${TMPDIR}\" -b 1024 -m 2000",
293 "fsbuffer-w" => {
295 "cat" => 'system',
297 "options" => "-w -t 30 -d \"${TMPDIR}\" -b 256 -m 500",
299 "fsbuffer-r" => {
301 "cat" => 'system',
303 "options" => "-r -t 30 -d \"${TMPDIR}\" -b 256 -m 500",
307 "cat" => 'system',
309 "options" => "-c -t 30 -d \"${TMPDIR}\" -b 256 -m 500",
311 "fsdisk-w" => {
313 "cat" => 'system',
315 "options" => "-w -t 30 -d \"${TMPDIR}\" -b 4096 -m 8000",
317 "fsdisk-r" => {
319 "cat" => 'system',
321 "options" => "-r -t 30 -d \"${TMPDIR}\" -b 4096 -m 8000",
325 "cat" => 'system',
327 "options" => "-c -t 30 -d \"${TMPDIR}\" -b 4096 -m 8000",
331 "cat" => 'system',
337 "cat" => 'system',
343 "cat" => 'system',
352 "2d-rects" => {
355 "prog" => "${BINDIR}/gfx-x11",
359 "2d-lines" => {
362 "prog" => "${BINDIR}/gfx-x11",
366 "2d-circle" => {
369 "prog" => "${BINDIR}/gfx-x11",
373 "2d-ellipse" => {
376 "prog" => "${BINDIR}/gfx-x11",
380 "2d-shapes" => {
383 "prog" => "${BINDIR}/gfx-x11",
387 "2d-aashapes" => {
390 "prog" => "${BINDIR}/gfx-x11",
394 "2d-polys" => {
397 "prog" => "${BINDIR}/gfx-x11",
401 "2d-text" => {
404 "prog" => "${BINDIR}/gfx-x11",
408 "2d-blit" => {
411 "prog" => "${BINDIR}/gfx-x11",
415 "2d-window" => {
418 "prog" => "${BINDIR}/gfx-x11",
425 "options" => "-time 20 -v",
430 ## Non-Index Benchmarks ##
477 "logmsg" => "Recursion Test -- Tower of Hanoi",
482 "logmsg" => "Grep a large file (system's grep)",
485 "options" => "30 grep -c gimp large.txt",
488 "logmsg" => "Exec System Call Overhead",
506 'xmm2' => "Streaming SIMD-2",
507 'xmm3' => "Streaming SIMD-3",
508 'ht' => "Hyper-Threading",
509 'ia64' => "IA-64 processor",
510 'lm' => "x86-64",
524 sub command {
527 my $pid = open(my $childFd, "-|");
539 # Get data from running a system command. Used for things like getting
540 # the host OS from `uname -o` etc.
543 # non-blank line, with white space trimmed off. Returns a blank string
545 sub getCmdOutput {
570 sub getDir {
583 sub createDirrectoriesIfNotExists {
585 my $isDirectoryNotExists = ! -d $path;
593 sub printUsingDirectories {
594 printf "------------------------------------------------------------------------------\n";
598 printf "------------------------------------------------------------------------------\n";
605 sub logFile {
617 my $ymd = strftime "%Y-%m-%d", localtime;
621 my $log = sprintf "%s/%s-%s-%02d",
622 ${RESULTDIR}, $sysInfo->{'name'}, $ymd, $count;
623 return $log if (! -e $log);
632 sub printLog {
641 # Display a number of something, auto-selecting the plural form
644 sub number {
657 # Merge two sets of test parameters -- defaults and actual parameters.
659 sub mergeParams {
664 $params->{$k} = $def->{$k};
667 $params->{$k} = $vals->{$k};
675 # SYSTEM ANALYSIS
680 sub processCpuFlags {
685 my $name = $x86CpuFlags->{$f};
693 # Get information on the CPUs in the system. Returns a reference to an
700 sub getCpuInfo {
715 $cpus->[$cpu]{'model'} = $model;
717 $cpus->[$cpu]{'bogo'} = $val;
719 $cpus->[$cpu]{'flags'} = processCpuFlags($val);
729 my $model = getCmdOutput("sysctl -n machdep.cpu.brand_string");
730 my $flags = getCmdOutput("sysctl -n machdep.cpu.features | tr [A-Z] [a-z]");
731 my $ncpu = getCmdOutput("sysctl -n hw.ncpu");
737 $cpus->[$cpu]{'model'} = $model;
738 $cpus->[$cpu]{'bogo'} = 0;
739 $cpus->[$cpu]{'flags'} = processCpuFlags($flags);
747 # or, if not num of available CPUs, the total number of CPUs on the system
750 # There is no shortage of platform-specific methods to obtain this info.
751 # This routine -is not- exhaustive, but adds some additional portability.
753 sub getNumActiveCpus {
769 …$numCpus = `python -c 'import os; print os.sysconf(os.sysconf_names["SC_NPROCESSORS_ONLN"]);' 2>/d…
779 # Get information on the host system. Returns a reference to a hash
788 # system System name (eg. hostname and Linux distro, like
792 # load System load message as per "uptime".
794 sub getSystemInfo {
797 # Get host system data.
798 $info->{'name'} = getCmdOutput("hostname");
799 $info->{'os'} = getCmdOutput("uname -o") || getCmdOutput("uname -s");
800 $info->{'osRel'} = getCmdOutput("uname -r");
801 $info->{'osVer'} = getCmdOutput("uname -v");
802 $info->{'mach'} = $^O ne "aix"
803 ? getCmdOutput("uname -m")
804 : getCmdOutput("uname -p");
805 $info->{'platform'} = getCmdOutput("uname -i") || "unknown";
807 # Get the system name (SUSE, Red Hat, etc.) if possible.
808 $info->{'system'} = $info->{'os'};
809 if ( -r "/etc/SuSE-release" ) {
810 $info->{'system'} = getCmdOutput("cat /etc/SuSE-release");
811 } elsif ( -r "/etc/release" ) {
812 $info->{'system'} = getCmdOutput("cat /etc/release");
818 ? getCmdOutput("locale -k LC_CTYPE | grep charmap") || ""
822 ? getCmdOutput("locale -k LC_COLLATE | grep collate-codeset") || ""
825 $info->{'language'} = sprintf "%s (charmap=%s, collate=%s)",
831 $info->{'cpus'} = $cpus;
832 $info->{'numCpus'} = scalar(@$cpus);
838 $info->{'numCpus'} = $numCpus; # overwrite value from getCpuinfo()
842 $info->{'graphics'} = getCmdOutput("3dinfo | cut -f1 -d\'(\'");
844 # Get system run state, load and usage info.
845 $info->{'runlevel'} = getCmdOutput("who -r | awk '{print \$3}'");
846 $info->{'load'} = getCmdOutput("uptime");
847 $info->{'numUsers'} = getCmdOutput("who | wc -l");
858 sub abortRun {
872 sub preChecks {
878 system("$make check");
880 system("$make all");
887 system("echo \"kill -9 $$\" > \"${TMPDIR}/kill_run\"");
893 sub parseArgs {
904 if ($word !~ m/^-/) { # A test name.
907 push(@$tests, $t) if (!defined($testList->{$t}));
909 } elsif (exists($testList->{$word})) {
910 my $val = $testList->{$word} || [ $word ];
915 } elsif ($word eq "-q") {
916 $params->{'verbose'} = 0;
917 } elsif ($word eq "-v") {
918 $params->{'verbose'} = 2;
919 } elsif ($word eq "-i") {
920 $params->{'iterations'} = shift(@words);
921 } elsif ($word eq "-c") {
922 if (!defined($params->{'copies'})) {
923 $params->{'copies'} = [ ];
925 push(@{$params->{'copies'}}, shift(@words));
942 sub readResultsFromFile {
958 $bresult->{'score'} = $score;
959 $bresult->{'scorelabel'} = $slab;
960 $bresult->{'time'} = $time;
961 $bresult->{'iterations'} = $iters;
963 $results->{$name} = $bresult;
979 # glitch in the system (background process waking up, for example) may
983 # $bresult->{'passes'} is an array of the output from the individual
985 sub combinePassResults {
988 $bresult->{'cat'} = $tdata->{'cat'};
997 my $pres = $bresult->{'passes'};
1004 foreach my $presult (sort { $a->{'COUNT0'} <=> $b->{'COUNT0'} } @$pres) {
1005 my $count = $presult->{'COUNT0'};
1006 my $timebase = $presult->{'COUNT1'};
1007 $label = $presult->{'COUNT2'};
1008 my $time = $presult->{'TIME'} || $presult->{'elapsed'};
1013 --$ndump;
1025 $product += log($count) - log($time / $timebase) if ($count > 0);
1035 $bresult->{'score'} = exp($product / $iterations);
1036 $bresult->{'scorelabel'} = $label;
1037 $bresult->{'time'} = $totalTime / $iterations;
1038 $bresult->{'iterations'} = $iterations;
1040 $bresult->{'error'} = "No measured results";
1054 # fullindex Non-0 if all the index tests were indexed
1060 sub indexResults {
1073 foreach my $bench (@{$results->{'list'}}) {
1074 my $bresult = $results->{$bench};
1075 ++$numCat->{$bresult->{'cat'}};
1077 $results->{'numCat'} = $numCat;
1084 my $tdata = $testParams->{$bench};
1090 my $cat = $tdata->{'cat'};
1091 ++$numIndex->{$cat};
1094 next if (!defined($results->{$bench}));
1097 my $iresult = $index->{$bench};
1098 my $bresult = $results->{$bench};
1099 my $ratio = $bresult->{'score'} / $iresult->{'score'};
1102 $bresult->{'iscore'} = $iresult->{'score'};
1103 $bresult->{'index'} = $ratio * 10;
1106 $sum->{$cat} += log($ratio) if ($ratio > 0.000001);
1107 ++$indexed->{$cat};
1111 $results->{'indexed'} = $indexed;
1112 $results->{'numIndex'} = $numIndex;
1114 if ($indexed->{$c} > 0) {
1115 $results->{'index'}{$c} = exp($sum->{$c} / $indexed->{$c}) * 10;
1125 # Exec the given command in a sub-process.
1135 sub commandBuffered {
1138 # Create a pipe for parent-child communication.
1142 $parentWriter->autoflush(1);
1163 my $elTime = Time::HiRes::time() - $benchStart;
1202 sub readResults {
1213 $presult->{'ERROR'} .= "\n" if ($presult->{'ERROR'});
1214 $presult->{'ERROR'} .= $field;
1216 $presult->{$field} = $params[0];
1220 $presult->{$field . $x} = $params[$x];
1227 if ($presult->{'status'} != 0 && !defined($presult->{'ERROR'})) {
1228 $presult->{'ERROR'} = "command returned status " . $presult->{'status'};
1244 sub executeBenchmark {
1253 $ctxt->[$i] = {
1264 my $presult = readResults($ctxt->[$i]{'pid'}, $ctxt->[$i]{'fd'});
1275 sub runOnePass {
1279 my $command = $params->{'command'};
1304 printLog($logFile, "# %s: %s\n", $k, $res->{$k});
1309 if (defined($res->{'ERROR'})) {
1310 my $name = $params->{'logmsg'};
1311 abortRun("\"$name\": " . $res->{'ERROR'});
1315 $count += $res->{'COUNT0'};
1316 $time += $res->{'TIME'} || $res->{'elapsed'};
1317 $elap += $res->{'elapsed'};
1321 my $passResult = $copyResults->[0];
1322 $passResult->{'COUNT0'} = $count;
1323 $passResult->{'TIME'} = $time / $copies;
1324 $passResult->{'elapsed'} = $elap / $copies;
1330 sub runBenchmark {
1337 my $prog = $params->{'prog'} || $BINDIR . "/" . $bench;
1338 my $command = sprintf "\"%s\" %s", $prog, $params->{'options'};
1339 $command .= " < \"" . $params->{'stdin'} . "\"" if ($params->{'stdin'});
1341 $command .= $params->{'stdout'} ? (" >> \"" . $logFile . "\"") : " > /dev/null";
1342 $params->{'command'} = $command;
1345 my $bresult = { 'name' => $bench, 'msg' => $params->{'logmsg'} };
1348 printf "\n%d x %s ", $copies, $params->{'logmsg'};
1353 printLog($logFile, "%s -- %s\n",
1354 $params->{'logmsg'}, number($copies, "copy", "copies"));
1359 $repeats = $longIterCount if $params->{'repeat'} eq 'long';
1360 $repeats = 1 if $params->{'repeat'} eq 'single';
1366 system("sync; sleep 1; sync; sleep 2");
1376 $bresult->{'passes'} = $pres;
1388 printLog($logFile, ">>>> %s: %s\n", $k, $bresult->{$k});
1407 sub runTests {
1414 my $params = $testParams->{$bench};
1420 my $cat = $params->{'cat'};
1421 my $maxCopies = $testCats->{$cat}{'maxCopies'};
1426 $results->{$bench} = $bresult;
1428 $results->{'end'} = time();
1432 ref($results->{$_}) eq "HASH" && defined($results->{$_}{'msg'})
1435 $results->{$a}{'msg'} cmp $results->{$b}{'msg'}
1437 $results->{'list'} = \@benches;
1450 # Display a banner indicating the configuration of the system under test
1452 sub displaySystem {
1455 # Display basic system info.
1456 printf $fd " System: %s: %s\n", $info->{'name'}, $info->{'system'};
1457 printf $fd " OS: %s -- %s -- %s\n",
1458 $info->{'os'}, $info->{'osRel'}, $info->{'osVer'};
1459 printf $fd " Machine: %s (%s)\n", $info->{'mach'}, $info->{'platform'};
1460 printf $fd " Language: %s\n", $info->{'language'};
1463 my $cpus = $info->{'cpus'};
1469 $i, $cpus->[$i]{'model'}, $cpus->[$i]{'bogo'};
1470 printf $fd " %s\n", $cpus->[$i]{'flags'};
1474 if ($info->{'graphics'}) {
1475 printf $fd " Graphics: %s\n", $info->{'graphics'};
1478 # Display system load and usage info.
1479 printf $fd " %s; runlevel %s\n\n", $info->{'load'}, $info->{'runlevel'};
1484 sub logResults {
1488 foreach my $bench (@{$results->{'list'}}) {
1489 my $bresult = $results->{$bench};
1491 printf $outFd "%-40s %12.1f %-5s (%.1f s, %d samples)\n",
1492 $bresult->{'msg'},
1493 $bresult->{'score'},
1494 $bresult->{'scorelabel'},
1495 $bresult->{'time'},
1496 $bresult->{'iterations'};
1504 sub logIndexCat {
1507 my $total = $results->{'numIndex'}{$cat};
1508 my $indexed = $results->{'indexed'}{$cat};
1509 my $iscore = $results->{'index'}{$cat};
1515 $testCats->{$cat}{'name'};
1521 my $head = $testCats->{$cat}{'name'} .
1523 printf $outFd "%-40s %12s %12s %8s\n",
1527 foreach my $bench (@{$results->{'list'}}) {
1528 my $bresult = $results->{$bench};
1529 next if $bresult->{'cat'} ne $cat;
1531 if (defined($bresult->{'iscore'}) && defined($bresult->{'index'})) {
1532 printf $outFd "%-40s %12.1f %12.1f %8.1f\n",
1533 $bresult->{'msg'}, $bresult->{'iscore'},
1534 $bresult->{'score'}, $bresult->{'index'};
1536 printf $outFd "%-40s %12s %12.1f %8s\n",
1537 $bresult->{'msg'}, "---",
1538 $bresult->{'score'}, "---";
1543 my $title = $testCats->{$cat}{'name'} . " Index Score";
1547 printf $outFd "%-40s %12s %12s %8s\n", "", "", "", "========";
1548 printf $outFd "%-66s %8.1f\n", $title, $iscore;
1555 sub logIndex {
1558 my $count = $results->{'indexed'};
1566 sub summarizeRun {
1570 printf $reportFd "------------------------------------------------------------------------\n";
1571 printf $reportFd "Benchmark Run: %s %s - %s\n",
1572 strftime("%a %b %d %Y", localtime($results->{'start'})),
1573 strftime("%H:%M:%S", localtime($results->{'start'})),
1574 strftime("%H:%M:%S", localtime($results->{'end'}));
1575 printf $reportFd "%s in system; running %s of tests\n",
1576 number($systemInfo->{'numCpus'}, "CPU"),
1577 number($results->{'copies'}, "parallel copy", "parallel copies");
1589 # e.g.: "Concurrency,Dhrystone 2 using register variables,Double-Precision Whetstone"
1591 sub summarizeRunCsvHeader {
1598 foreach my $bench (@{$results->{'list'}}) {
1599 my $bresult = $results->{$bench};
1600 printf $reportFd ",%s", $bresult->{'msg'};
1605 # Write CSV data rows per concurrency as "./Run -c 1 -c 2".
1610 sub summarizeRunCsvRows {
1614 printf $reportFd "%d", $results->{'copies'};
1618 foreach my $bench (@{$results->{'list'}}) {
1619 my $bresult = $results->{$bench};
1621 printf $reportFd ",%.1f", $bresult->{'score'};
1635 sub runHeaderHtml {
1640 $systemInfo->{'name'}, $systemInfo->{'system'},
1644 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
1648 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
1656 border-collapse: collapse;
1666 text-align: center;
1680 # Display a banner indicating the configuration of the system under test
1682 sub displaySystemHtml {
1685 printf $fd "<h3>Test System Information</h3>\n";
1688 # Display basic system info.
1690 printf $fd " <td><b>System:</b></td>\n";
1692 $info->{'name'}, $info->{'system'};
1695 printf $fd " <td colspan=2>%s -- %s -- %s</td>\n",
1696 $info->{'os'}, $info->{'osRel'}, $info->{'osVer'};
1700 $info->{'mach'}, $info->{'platform'};
1703 printf $fd " <td colspan=2>%s</td>\n", $info->{'language'};
1707 my $cpus = $info->{'cpus'};
1721 $cpus->[$i]{'model'}, $cpus->[$i]{'bogo'};
1722 printf $fd " %s</td>\n", $cpus->[$i]{'flags'};
1728 if ($info->{'graphics'}) {
1731 printf $fd " <td colspan=2>%s</td>\n", $info->{'graphics'};
1735 # Display system runlevel, load and usage info.
1739 $info->{'load'}, $info->{'runlevel'};
1748 sub logCatResultsHtml {
1751 my $numIndex = $results->{'numIndex'}{$cat};
1752 my $indexed = $results->{'indexed'}{$cat};
1753 my $iscore = $results->{'index'}{$cat};
1757 if (!defined($results->{'numCat'}{$cat}) ||
1758 $results->{'numCat'}{$cat} == 0) {
1770 printf $fd "<h4>%s%s</h4>\n", $testCats->{$cat}{'name'}, $warn;
1785 foreach my $bench (@{$results->{'list'}}) {
1786 my $bresult = $results->{$bench};
1787 next if $bresult->{'cat'} ne $cat;
1790 printf $fd " <td><b>%s</b></td>\n", $bresult->{'msg'};
1792 $bresult->{'score'};
1794 $bresult->{'scorelabel'};
1796 $bresult->{'time'};
1798 $bresult->{'iterations'};
1800 if (defined($bresult->{'index'})) {
1802 $bresult->{'iscore'};
1804 $bresult->{'index'};
1811 my $title = $testCats->{$cat}{'name'} . " Index Score";
1826 sub logResultsHtml {
1836 sub summarizeRunHtml {
1840 my $time = $results->{'end'} - $results->{'start'};
1843 number($systemInfo->{'numCpus'}, "CPU"),
1844 number($results->{'copies'}, "parallel process", "parallel processes");
1845 printf $reportFd "<p>Time: %s - %s; %dm %02ds</p>\n",
1846 strftime("%H:%M:%S", localtime($results->{'start'})),
1847 strftime("%H:%M:%S", localtime($results->{'end'})),
1856 sub runFooterHtml {
1864 respecting non-infringement, and the implied warranties of conditions
1882 sub main {
1886 my $verbose = $params->{'verbose'} || 1;
1887 if ($params->{'iterations'}) {
1888 $longIterCount = $params->{'iterations'};
1889 $shortIterCount = int(($params->{'iterations'} + 1) / 3);
1894 my $tests = $params->{'tests'};
1907 # and the number of CPUs in the system (if > 1).
1908 my $copies = $params->{'copies'};
1911 if (defined($systemInfo->{'numCpus'}) && $systemInfo->{'numCpus'} > 1) {
1912 push(@$copies, $systemInfo->{'numCpus'});
1917 system("cat \"${BINDIR}/unixbench.logo\"");
1955 # Dump information about the system under test.
1960 # for example, on a 2-CPU system, we may do a single-processing run
1961 # followed by a dual-processing run.
1993 system("cat \"$reportFile\"");