getbg 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806
  1. # Extract bargraph data from lmbench results.
  2. # Usage: getbg file file file....
  3. #
  4. # Hacked into existence by Larry McVoy (lm@sun.com now lm@sgi.com).
  5. # Copyright (c) 1994 Larry McVoy. GPLed software.
  6. # $Id$
  7. eval 'exec perl -Sws $0 "$@"'
  8. if 0;
  9. @bw_file = @file = @lat_ctx32_8 = @lat_ctx32 = @lat_ctx8 = @lat_ctx =
  10. @lat_shproc = @lat_simpleproc = @lat_nullproc =
  11. @lat_rpc_tcp_local = @lat_rpc_udp_local = @lat_tcp_local = @lat_udp_local =
  12. @lat_pipe = @lat_disk = @mhz = @lat_fs_delete = @lat_fs_create =
  13. @lat_mappings = @lat_pagefault = @lat_connect = @lat_signal = @lat_sigaction =
  14. @lat_nullsys = @lat_mem = @lat_l2 = @lat_l1 = ();
  15. $nosort = $v = $paper = $slide = 0 if 0;
  16. $sortN = 0;
  17. $n = 0;
  18. foreach $file (@ARGV) {
  19. warn "$0: doing $file\n" if $v;
  20. open(FD, $file) || die "$0: can't open $file";
  21. $file =~ s|/|-|;
  22. $file =~ s/\.\d+//;
  23. push(@file, $file);
  24. while (<FD>) {
  25. chop;
  26. next if m|scripts/lmbench: /dev/tty|;
  27. if (/^\[lmbench/) {
  28. @_ = split;
  29. if ($_[3] eq "SunOS") {
  30. $_[3] .= "-$_[5]";
  31. }
  32. push(@uname, "@_");
  33. }
  34. if (/Mhz/) {
  35. @_ = split;
  36. push(@misc_mhz, $_[0]);
  37. }
  38. if (/^Null syscall:/) {
  39. @_ = split;
  40. push(@lat_nullsys, $_[2]);
  41. }
  42. if (/^Signal handler installation:/) {
  43. @_ = split;
  44. push(@lat_sigaction, $_[3]);
  45. }
  46. if (/^Signal handler overhead:/) {
  47. @_ = split;
  48. push(@lat_signal, $_[3]);
  49. }
  50. if (/^Pipe latency:/) {
  51. @_ = split;
  52. push(@lat_pipe, $_[2]);
  53. }
  54. if (/UDP latency using localhost:/) {
  55. @_ = split;
  56. push(@lat_udp_local, $_[4]);
  57. }
  58. if (/TCP latency using localhost/) {
  59. @_ = split;
  60. push(@lat_tcp_local, $_[4]);
  61. }
  62. if (/RPC.udp latency using localhost/) {
  63. @_ = split;
  64. push(@lat_rpc_udp_local, $_[4]);
  65. }
  66. if (/RPC.tcp latency using localhost/) {
  67. @_ = split;
  68. push(@lat_rpc_tcp_local, $_[4]);
  69. }
  70. if (/TCP\/IP connection cost to localhost/) {
  71. @_ = split;
  72. push(@lat_connect, $_[5]);
  73. }
  74. if (/^Process fork.exit/) {
  75. @_ = split;
  76. push(@lat_nullproc, $_[2]);
  77. }
  78. if (/^Process fork.execve:/) {
  79. @_ = split;
  80. push(@lat_simpleproc, $_[2]);
  81. }
  82. if (/^Process fork..bin.sh/) {
  83. @_ = split;
  84. push(@lat_shproc, $_[3]);
  85. }
  86. if (/^Pagefaults on/) {
  87. @_ = split;
  88. push(@lat_pagefault, $_[3]);
  89. }
  90. if (/size=0 ovr=/) {
  91. while (<FD>) {
  92. # Make sure we break out if no data here.
  93. if (!/^[1-9]+\s/) {
  94. warn "$file: No ctx found\n";
  95. push(@lat_ctx, -1);
  96. }
  97. next unless /^2/;
  98. @_ = split;
  99. push(@lat_ctx, $_[1]);
  100. last;
  101. }
  102. while (<FD>) {
  103. # Make sure we break out if no data here.
  104. if (!/^[1-9]+\s/) {
  105. warn "$file: No ctx found\n";
  106. push(@lat_ctx, -1);
  107. }
  108. next unless /^8/;
  109. @_ = split;
  110. push(@lat_ctx8, $_[1]);
  111. last;
  112. }
  113. }
  114. if (/size=32 ovr=/) {
  115. while (<FD>) {
  116. # Make sure we break out if no data here.
  117. if (!/^[1-9]+\s/) {
  118. warn "$file: No ctx found\n";
  119. push(@lat_ctx32, -1);
  120. }
  121. next unless /^2/;
  122. @_ = split;
  123. push(@lat_ctx32, $_[1]);
  124. last;
  125. }
  126. while (<FD>) {
  127. # Make sure we break out if no data here.
  128. if (!/^[1-9]+\s/) {
  129. warn "$file: No ctx found\n";
  130. push(@lat_ctx32_8, -1);
  131. }
  132. next unless /^8/;
  133. @_ = split;
  134. push(@lat_ctx32_8, $_[1]);
  135. last;
  136. }
  137. }
  138. if (/^Pipe bandwidth/) {
  139. @_ = split;
  140. push(@bw_pipe, $_[2]);
  141. }
  142. if (/^Socket bandwidth using localhost/) {
  143. @_ = split;
  144. push(@bw_tcp_local, $_[4]);
  145. }
  146. if (/^Disk .* latency:/) {
  147. @_ = split;
  148. push(@lat_disk, $_[3]);
  149. }
  150. if (/^File .* write bandwidth/) {
  151. @_ = split;
  152. $bw = sprintf("%.2f", $_[4] / 1024.);
  153. push(@bw_file, $bw);
  154. }
  155. if (/^"mappings/) {
  156. $value = &getbiggest("memory mapping timing");
  157. push(@lat_mappings, $value);
  158. }
  159. if (/^"read bandwidth/) {
  160. $value = &getbiggest("reread timing");
  161. push(@bw_reread, $value);
  162. }
  163. if (/^"Mmap read bandwidth/) {
  164. $value = &getbiggest("mmap reread timing");
  165. push(@bw_mmap, $value);
  166. }
  167. if (/^"libc bcopy unaligned/) {
  168. $value = &getbiggest("libc bcopy timing");
  169. push(@bw_bcopy_libc, $value);
  170. }
  171. if (/^"unrolled bcopy unaligned/) {
  172. $value = &getbiggest("unrolled bcopy timing");
  173. push(@bw_bcopy_unrolled, $value);
  174. }
  175. if (/^Memory read/) {
  176. $value = &getbiggest("memory read & sum timing");
  177. push(@bw_mem_rdsum, $value);
  178. }
  179. if (/^Memory write/) {
  180. $value = &getbiggest("memory write timing");
  181. push(@bw_mem_wr, $value);
  182. }
  183. if (/^0k\s/) {
  184. @_ = split;
  185. push(@lat_fs_create, int(1000000/$_[2]));
  186. push(@lat_fs_delete, int(1000000/$_[3]));
  187. }
  188. if (/^"stride=128/) {
  189. $save = -1;
  190. while (<FD>) {
  191. if (/^0.00098\s/) {
  192. @_ = split;
  193. push(@lat_l1, $_[1]);
  194. } elsif (/^0.12500\s/) {
  195. @_ = split;
  196. push(@lat_l2, $_[1]);
  197. } elsif (/^[45678].00000\s/) {
  198. @_ = split;
  199. $size = $_[0];
  200. $save = $_[1];
  201. last if /^8.00000\s/;
  202. } elsif (/^\s*$/) {
  203. last;
  204. }
  205. }
  206. if (!/^8/) {
  207. warn "$file: No 8MB memory latency, using $size\n";
  208. }
  209. push(@lat_mem, $save);
  210. }
  211. }
  212. foreach $array (
  213. 'misc_mhz', 'lat_nullsys', 'lat_pipe', 'lat_udp_local',
  214. 'lat_tcp_local', 'lat_rpc_udp_local', 'lat_connect',
  215. 'lat_rpc_tcp_local', 'lat_nullproc', 'lat_simpleproc',
  216. 'lat_ctx', 'lat_ctx8', 'bw_pipe', 'bw_tcp_local',
  217. 'bw_file', 'lat_mappings', 'bw_reread', 'bw_mmap',
  218. 'bw_bcopy_libc', 'bw_bcopy_unrolled', 'bw_mem_rdsum',
  219. 'bw_mem_wr', 'lat_l1', 'lat_l2', 'lat_mem', 'lat_disk',
  220. ) {
  221. $last = eval '$#' . $array;
  222. if ($last != $n) {
  223. warn "No data for $array in $file\n";
  224. eval 'push(@' . $array . ', -1);';
  225. }
  226. }
  227. $n++;
  228. }
  229. if ($paper) {
  230. &tbl("lat_nullsys", "usecs", "system call");
  231. &tbl2("lat_signal", "lat_sigaction", "lat_signal", "usecs",
  232. "signal", "sigaction", "sig handler");
  233. #&tbl("lat_nullproc", "msecs", "Process fork/exit time in milliseconds");
  234. #&tbl("lat_simpleproc", "msecs", "Simple process create time in milliseconds");
  235. #&tbl("lat_shproc", "msecs", "Process creates via /bin/sh time in milliseconds");
  236. #&tbl2("lat_proc", "lat_simpleproc", "lat_shproc", "usecs",
  237. # "Process create time in milliseconds", "exec(2)", "/bin/sh -c");
  238. &procs("lat_allproc", "lat_nullproc", "lat_simpleproc", "lat_shproc",
  239. "msecs");
  240. &ctx;
  241. &tbl("lat_pipe", "usecs", "Pipe latency");
  242. &tbl("lat_connect", "usecs", "TCP connection");
  243. &tbl2("lat_udp", "lat_udp_local", "lat_rpc_udp_local", "usecs",
  244. "UDP latency in \\(*mseconds", "UDP", "RPC/UDP");
  245. &tbl2("lat_tcp", "lat_tcp_local", "lat_rpc_tcp_local", "usecs",
  246. "TCP latency in \\(*mseconds", "TCP", "RPC/TCP");
  247. &tbl("lat_mappings", "usecs", "Memory mapping latency in \\(*mseconds");
  248. &tbl("lat_pagefault", "usecs", "Pagefault latency in \\(*mseconds");
  249. &tbl2("lat_fs", "lat_fs_create", "lat_fs_delete", "usecs",
  250. "File latency in milliseconds", "Create", "Delete");
  251. &tbl("lat_disk", "usecs", "Disk latency");
  252. &tbl("misc_mhz", "mhz", "Processor clock rate");
  253. &tbl("bw_pipe", "MB", "Pipe bandwidth in MB / second");
  254. &tbl("bw_tcp_local", "MB", "Local TCP socket bandwidth in MB / second");
  255. &ipc;
  256. &tbl("bw_file", "MB", "File write bandwidth in MB / second");
  257. &tbl("bw_reread", "MB", "(Re)Read in MB / second");
  258. &tbl("bw_mmap", "MB", "(Re)Read via mmap bandwidth in MB / second");
  259. &read;
  260. &tbl2("bw_bcopy", "bw_bcopy_unrolled", "bw_bcopy_libc", "MB",
  261. "Bcopy bandwidth in MB / second", "Unrolled", "Libc");
  262. &tbl("bw_mem_rdsum", "MB", "Memory read & sum bandwidth in MB / second");
  263. &tbl("bw_mem_wr", "MB", "Memory write bandwidth in MB / second");
  264. &mem;
  265. } else {
  266. &bg("lat_nullsys", "usecs", "Number of null system calls per second");
  267. &bg("lat_signal", "usecs", "Number of signal handlers per second");
  268. &bg("lat_nullproc", "usecs", "Number of process forks/exits per second");
  269. &bg("lat_simpleproc", "usecs", "Number of simple process creates per second");
  270. &bg("lat_shproc", "usecs", "Number of simple process creates via /bin/sh per second");
  271. &bg("lat_ctx", "usecs", "Number of context switches per second, 2 small processes");
  272. &bg("lat_ctx8", "usecs", "Number of context switches per second, 8 small processes");
  273. &bg("lat_pipe", "usecs", "Number of pipe transactions per second");
  274. &bg("lat_connect", "usecs", "Number of local TCP socket connections per second");
  275. &bg("lat_tcp_local", "usecs", "Number of local TCP socket transactions per second");
  276. &bg("lat_udp_local", "usecs", "Number of local UDP socket transactions per second");
  277. &bg("lat_rpc_udp_local", "usecs",
  278. "Number of local RPC/UDP socket transactions per second");
  279. &bg("lat_rpc_tcp_local", "usecs",
  280. "Number of local RPC/TCP socket transactions per second");
  281. &bg("lat_mappings", "usecs", "Number of memory mappings per second");
  282. &bg("lat_pagefault", "usecs", "Number of pagefaults per second");
  283. &bg("lat_fs_create", "usecs", "Number of file creates per second");
  284. &bg("misc_mhz", "mhz", "Processor clock rate");
  285. &bg("bw_pipe", "MB", "Pipe bandwidth in MB / second");
  286. &bg("bw_tcp_local", "MB", "Local TCP socket bandwidth in MB / second");
  287. &bg("bw_file", "MB", "File write bandwidth in MB / second");
  288. &bg("bw_reread", "MB", "(Re)Read in MB / second");
  289. &bg("bw_mmap", "MB", "(Re)Read via mmap bandwidth in MB / second");
  290. &bg("bw_bcopy_libc", "MB", "Libc bcopy bandwidth in MB / second");
  291. &bg("bw_bcopy_unrolled", "MB", "Unrolled bcopy bandwidth in MB / second");
  292. &bg("bw_mem_rdsum", "MB", "Memory read & sum bandwidth in MB / second");
  293. &bg("bw_mem_wr", "MB", "Memory write bandwidth in MB / second");
  294. }
  295. exit 0;
  296. # Input looks like
  297. # "benchmark name
  298. # size value
  299. # ....
  300. # <blank line>
  301. #
  302. # Return the biggest vvalue before the blank line.
  303. sub getbiggest
  304. {
  305. local($msg) = @_;
  306. undef $save;
  307. $value = 0;
  308. while (<FD>) {
  309. last if /^\s*$/;
  310. $save = $_ if /^\d\./;
  311. }
  312. if (defined $save) {
  313. $_ = $save;
  314. @d = split;
  315. $value = $d[1];
  316. } else {
  317. warn "$file: no data for $msg\n";
  318. }
  319. $value;
  320. }
  321. sub bigger
  322. {
  323. local($v1, $v2) = ($a, $b);
  324. if ($sortN > 0) {
  325. $v1 = (split(/\t/, $v1))[$sortN];
  326. $v2 = (split(/\t/, $v2))[$sortN];
  327. } else {
  328. $v1 =~ s/.*\t//;
  329. chop($v1);
  330. $v2 =~ s/.*\t//;
  331. chop($v2);
  332. }
  333. return ($v1 < $v2);
  334. }
  335. sub smaller
  336. {
  337. local($v1, $v2) = ($a, $b);
  338. if ($sortN > 0) {
  339. $v1 = (split(/\t/, $v1))[$sortN];
  340. $v2 = (split(/\t/, $v2))[$sortN];
  341. } else {
  342. $v1 =~ s/.*\t//;
  343. chop($v1);
  344. $v2 =~ s/.*\t//;
  345. chop($v2);
  346. }
  347. $v1 =~ s/[^0-9]+//;
  348. $v2 =~ s/[^0-9]+//;
  349. return ($v1 > $v2);
  350. }
  351. sub tbl
  352. {
  353. local($graph, $units, $title) = @_;
  354. local(@values, @tmp, $persec, $value);
  355. warn "tmp/$graph.tbl\n" if $v;
  356. open(FD, ">tmp/$graph.tbl");
  357. print FD ".KS\n.TS\ncenter expand doublebox;\nl r.\nSystem\t$title\n=\n";
  358. for ($i = 0; $i <= $#uname; $i++) {
  359. @info = &getinfo($uname[$i], $misc_mhz[$i]);
  360. $XXX = '$value = $'.$graph.'[$i];';
  361. eval '$value = $'.$graph.'[$i];';
  362. $value = sprintf("%.1f", $value / 1000) if ($units eq "msecs");
  363. $value = sprintf("%.1f", $value) if ($units eq "MB");
  364. next if (!defined $value || $value <= 0);
  365. $_ = "$info[3] $info[$#info]";
  366. &papernames;
  367. push(@values, "$_\t$value\n");
  368. }
  369. @values = sort smaller @values unless ($nosort);
  370. # Somewhere an extra space is getting added.
  371. foreach $_ (@values) {
  372. s/^\s*//;
  373. print FD;
  374. }
  375. print FD ".TE\n.KE\n";
  376. close(FD);
  377. }
  378. sub tbl2
  379. {
  380. local($graph, $a, $b, $units, $title, $atitle, $btitle) = @_;
  381. local(@values, @tmp, $line, $persec, $value);
  382. warn "tmp/$graph.tbl\n" if $v;
  383. open(FD, ">tmp/$graph.tbl");
  384. print FD ".KS\n.TS\nexpand doublebox;\nl c c\nl r r.\n";
  385. print FD "System\t$atitle\t\\fB$btitle\\fP\n=\n";
  386. for ($i = 0; $i <= $#uname; $i++) {
  387. @info = &getinfo($uname[$i], $misc_mhz[$i]);
  388. eval '$value = $'.$a.'[$i];';
  389. next if (!defined $value || $value <= 0);
  390. $value = sprintf("%.1f", $value / 1000) if ($units eq "msecs");
  391. $value = sprintf("%.1f", $value) if ($units eq "MB");
  392. $_ = "$info[3] $info[$#info]";
  393. &papernames;
  394. $line = "$_\t$value\t";
  395. eval '$value = $'.$b.'[$i];';
  396. $value = sprintf("%.1f", $value / 1000) if ($units eq "msecs");
  397. $value = sprintf("%.1f", $value) if ($units eq "MB");
  398. next if (!defined $value || $value <= 0);
  399. $line .= "$value\n";
  400. push(@values, $line);
  401. }
  402. unless ($nosort || $units eq "mhz") {
  403. if ($units eq "MB") {
  404. @values = sort bigger @values;
  405. } else {
  406. @values = sort smaller @values;
  407. }
  408. }
  409. # Somewhere an extra space is getting added.
  410. foreach $_ (@values) {
  411. s/^\s*//;
  412. print FD;
  413. }
  414. print FD ".TE\n.KE\n";
  415. close(FD);
  416. }
  417. sub ipc
  418. {
  419. local(@values, @tmp, $line, $persec, $value);
  420. open(FD, ">tmp/bw_ipc.tbl");
  421. print FD ".KS\n.TS\nexpand doublebox;\nl c c c\nl r r r.\n";
  422. print FD "System\tLibc bcopy\t\\fBpipe\\fP\tTCP\n=\n";
  423. for ($i = 0; $i <= $#uname; $i++) {
  424. @info = &getinfo($uname[$i], $misc_mhz[$i]);
  425. $value = $bw_bcopy_libc[$i];
  426. $value = sprintf("%.0f", $value);
  427. next if ($value <= 0);
  428. $_ = "$info[3] $info[$#info]";
  429. &papernames;
  430. $line = "$_\t$value\t";
  431. $value = $bw_pipe[$i];
  432. $value = sprintf("%.0f", $value);
  433. next if ($value <= 0);
  434. $line .= "$value\t";
  435. $value = $bw_tcp_local[$i];
  436. $value = sprintf("%.0f", $value);
  437. # next if ($value <= 0);
  438. $line .= "$value\\ \n";
  439. push(@values, $line);
  440. }
  441. $sortN = 2;
  442. @values = sort bigger @values unless ($nosort);
  443. $sortN = 0;
  444. # Somewhere an extra space is getting added.
  445. foreach $_ (@values) {
  446. s/^\s*//;
  447. print FD;
  448. }
  449. print FD ".TE\n.KE\n";
  450. close(FD);
  451. }
  452. sub read
  453. {
  454. local(@values, @tmp, $line, $persec, $value);
  455. open(FD, ">tmp/bw_reread2.tbl");
  456. print FD ".KS\n.TS\nexpand doublebox;\nc|c c|c c\nl|c c|c c\nl|r r|r r.\n";
  457. print FD "\tLibc\t\\fBFile\\fP\tMemory\tFile\nSystem\tbcopy\t\\fBread\\fP\tread\tmmap\n=\n";
  458. for ($i = 0; $i <= $#uname; $i++) {
  459. @info = &getinfo($uname[$i], $misc_mhz[$i]);
  460. $value = $bw_bcopy_libc[$i];
  461. $value = sprintf("%.0f", $value);
  462. next if ($value <= 0);
  463. $_ = "$info[3] $info[$#info]";
  464. &papernames;
  465. $line = "$_\t$value\t";
  466. $value = $bw_reread[$i];
  467. $value = sprintf("%.0f", $value);
  468. next if ($value <= 0);
  469. $line .= "$value\t";
  470. $value = $bw_mem_rdsum[$i];
  471. $value = sprintf("%.0f", $value);
  472. next if ($value <= 0);
  473. $line .= "$value\t";
  474. $value = $bw_mmap[$i];
  475. $value = sprintf("%.0f", $value);
  476. next if ($value <= 0);
  477. $line .= "$value\\ \n";
  478. push(@values, $line);
  479. }
  480. $sortN = 2;
  481. @values = sort bigger @values unless ($nosort);
  482. $sortN = 0;
  483. # Somewhere an extra space is getting added.
  484. foreach $_ (@values) {
  485. s/^\s*//;
  486. print FD;
  487. }
  488. print FD ".TE\n.KE\n";
  489. close(FD);
  490. }
  491. sub mem
  492. {
  493. local(@values, @tmp, $line, $persec, $value);
  494. open(FD, ">tmp/bw_allmem.tbl");
  495. print FD ".KS\n.TS\nexpand doublebox;\nc|c s|c s\nl|c c|c c\nl|r r|r r.\n";
  496. print FD "\tBcopy\tMemory\nSystem\t\\fBunrolled\\fP\tlibc\tread\twrite\n=\n";
  497. for ($i = 0; $i <= $#uname; $i++) {
  498. @info = &getinfo($uname[$i], $misc_mhz[$i]);
  499. $value = $bw_bcopy_unrolled[$i];
  500. $value = sprintf("%.0f", $value);
  501. next if ($value <= 0);
  502. $_ = "$info[3] $info[$#info]";
  503. &papernames;
  504. $line = "$_\t$value\t";
  505. $value = $bw_bcopy_libc[$i];
  506. $value = sprintf("%.0f", $value);
  507. next if ($value <= 0);
  508. $line .= "$value\t";
  509. $value = $bw_mem_rdsum[$i];
  510. $value = sprintf("%.0f", $value);
  511. next if ($value <= 0);
  512. $line .= "$value\t";
  513. $value = $bw_mem_wr[$i];
  514. $value = sprintf("%.0f", $value);
  515. next if ($value <= 0);
  516. $line .= "$value\\ \n";
  517. push(@values, $line);
  518. }
  519. $sortN = 1;
  520. @values = sort bigger @values unless ($nosort);
  521. $sortN = 0;
  522. # Somewhere an extra space is getting added.
  523. foreach $_ (@values) {
  524. s/^\s*//;
  525. print FD;
  526. }
  527. print FD ".TE\n.KE\n";
  528. close(FD);
  529. @values = ();
  530. open(FD, ">tmp/lat_allmem.tbl");
  531. print FD ".KS\n.TS\nexpand doublebox;\nl c c c\nl c c c\nl r r r.\n";
  532. print FD "\tLevel 1\tLevel 2\tMain\n";
  533. print FD "System\tcache\tcache\tmemory\n=\n";
  534. for ($i = 0; $i <= $#uname; $i++) {
  535. @info = &getinfo($uname[$i], $misc_mhz[$i]);
  536. $value = $lat_l1[$i];
  537. next if ($value <= 0);
  538. if (&same($lat_l1[$i], $lat_l2[$i])) {
  539. $value = "--";
  540. }
  541. $_ = "$info[3] $info[$#info]";
  542. &papernames;
  543. $line = "$_\t$value\t";
  544. $value = $lat_l2[$i];
  545. next if ($value <= 0);
  546. if (!&same($lat_l1[$i], $lat_l2[$i]) &&
  547. &same($lat_l2[$i], $lat_mem[$i])) {
  548. $value = "--";
  549. }
  550. $line .= "$value\t";
  551. $value = $lat_mem[$i];
  552. next if ($value <= 0);
  553. $line .= "$value\\ \n";
  554. push(@values, $line);
  555. }
  556. $sortN = 3;
  557. @values = sort smaller @values unless ($nosort);
  558. $sortN = 0;
  559. # Somewhere an extra space is getting added.
  560. foreach $_ (@values) {
  561. s/^\s*//;
  562. print FD;
  563. }
  564. print FD ".TE\n.KE\n";
  565. close(FD);
  566. }
  567. sub procs
  568. {
  569. local($graph, $a, $b, $c, $units) = @_;
  570. local(@values, @tmp, $line, $persec, $value);
  571. warn "tmp/$graph.tbl\n" if $v;
  572. open(FD, ">tmp/$graph.tbl");
  573. print FD ".KS\n.TS\nexpand doublebox;\nl|c|c|c\nl|r|r|r.\n";
  574. print FD "\tfork\t\\fBfork, exec\\fP\tfork, exec\n";
  575. print FD "System\t& exit\t\\fB& exit\\fP\tsh -c & exit\n=\n";
  576. for ($i = 0; $i <= $#uname; $i++) {
  577. @info = &getinfo($uname[$i], $misc_mhz[$i]);
  578. eval '$value = $'.$a.'[$i];';
  579. $value = sprintf("%.1f", $value / 1000);
  580. next if ($value <= 0);
  581. $_ = "$info[3] $info[$#info]";
  582. &papernames;
  583. $line = "$_\t$value\t";
  584. eval '$value = $'.$b.'[$i];';
  585. $value = sprintf("%.0f", $value / 1000);
  586. next if ($value <= 0);
  587. $line .= "$value\\ \t";
  588. eval '$value = $'.$c.'[$i];';
  589. $value = sprintf("%.0f", $value / 1000);
  590. next if ($value <= 0);
  591. $line .= "$value\\ \n";
  592. push(@values, $line);
  593. }
  594. $sortN = 2;
  595. @values = sort smaller @values unless ($nosort);
  596. $sortN = 0;
  597. # Somewhere an extra space is getting added.
  598. foreach $_ (@values) {
  599. s/^\s*//;
  600. print FD;
  601. }
  602. print FD ".TE\n.KE\n";
  603. close(FD);
  604. }
  605. sub ctx
  606. {
  607. local(@values, @tmp, $line, $persec, $value);
  608. open(FD, ">tmp/ctx.tbl");
  609. print FD ".KS\n.TS\nexpand doublebox;\nc|c s|c s\nl|c c|c c\nl|r r|r r.\n";
  610. print FD "\t2 processes\t8 processes\nSystem\t\\fB0KB\\fP\t32KB\t0KB\t32KB\n=\n";
  611. for ($i = 0; $i <= $#uname; $i++) {
  612. @info = &getinfo($uname[$i], $misc_mhz[$i]);
  613. $_ = "$info[3] $info[$#info]";
  614. &papernames;
  615. $line = "$_\t";
  616. foreach $a ('lat_ctx', 'lat_ctx32', 'lat_ctx8', 'lat_ctx32_8') {
  617. eval '$value = $'.$a.'[$i];';
  618. $line .= "$value\t";
  619. }
  620. chop($line);
  621. push(@values, "$line\\ \n");
  622. }
  623. $sortN = 1;
  624. @values = sort smaller @values unless ($nosort);
  625. $sortN = 0;
  626. # Somewhere an extra space is getting added.
  627. foreach $_ (@values) {
  628. s/^\s*//;
  629. print FD;
  630. }
  631. print FD ".TE\n.KE\n";
  632. close(FD);
  633. }
  634. sub papernames
  635. {
  636. $_ = "IBM PowerPC" if /AIX powerpc\@134/;
  637. $_ = "IBM Power2" if /AIX rs6000-990\@71/;
  638. $_ = "FreeBSD/i586" if /FreeBSD i586\@13[01234]/;
  639. $_ = "HP 9000/819" if /HP-UX 9000.819\@/;
  640. $_ = "HP K210" if /HP-UX 9000.859\@/;
  641. $_ = "SGI Challenge/R10K" if /IRIX.* IP25\@/;
  642. $_ = "SGI Challenge/R4K" if /IRIX.* IP19\@/;
  643. $_ = "SGI Indigo2" if /IRIX.* IP22\@/;
  644. $_ = "Linux/Alpha" if /Linux alpha\@/;
  645. $_ = "Linux/i686" if /Linux i686\@/;
  646. $_ = "Linux/i586" if /Linux i586\@/;
  647. $_ = "DEC Alpha\@150" if /OSF1 alpha\@147/;
  648. $_ = "DEC Alpha\@300" if /OSF1 alpha\@303/;
  649. $_ = "Sun SC1000" if /SunOS-5.5 sun4d\@5/;
  650. $_ = "Sun Ultra1" if /SunOS-5.5 sun4u/;
  651. $_ = "Solaris/i686" if /SunOS-5.5.1 i86pc\@13/;
  652. $_ = "Unixware/i686" if /UNIX_SV x86at/;
  653. }
  654. sub bg
  655. {
  656. local($graph, $units, $title) = @_;
  657. local($persec, $value);
  658. if ($nosort) {
  659. open(FD, ">tmp/$graph.bg");
  660. } else {
  661. open(FD, "|sort -nr > tmp/$graph.bg");
  662. }
  663. for ($i = 0; $i <= $#uname; $i++) {
  664. @info = &getinfo($uname[$i], $misc_mhz[$i]);
  665. # eval "\$value = \$$graph[$i];";
  666. $XXX = '$value = $'.$graph.'[$i];';
  667. eval '$value = $'.$graph.'[$i];';
  668. if ($uname[$i] =~ /IRIX/) {
  669. $fill = " %%fill0";
  670. } elsif ($uname[$i] =~ /HP/) {
  671. $fill = " %%fill.3";
  672. } elsif ($uname[$i] =~ /AIX/) {
  673. $fill = " %%fill.1";
  674. } elsif ($uname[$i] =~ /OSF/) {
  675. $fill = " %%fill.5";
  676. } elsif ($uname[$i] =~ /Linux/) {
  677. $fill = " %%fill.7";
  678. } elsif ($uname[$i] =~ /Sun/) {
  679. $fill = " %%fill1";
  680. } else {
  681. $fill = "";
  682. }
  683. if ($units eq "usecs") {
  684. if (!defined $value || $value <= 0) {
  685. warn
  686. "$ARGV[$i] $graph $info[$#info]: value is 0\n";
  687. $persec = 0;
  688. $value = 0;
  689. } else {
  690. $persec = 1000000 / $value;
  691. }
  692. if (0) {
  693. printf FD
  694. "%.0f\t$info[3] $info[$#info] $value\\ $units$fill\n",
  695. $persec;
  696. } else {
  697. printf FD
  698. "%.0f\t%s %s $value\\ $units$fill\n",
  699. $persec, $file[$i], &getos($uname[$i]);
  700. }
  701. } elsif ($units eq "MB") {
  702. printf FD "$value\t$info[3] $info[$#info]$fill\n";
  703. } elsif ($units eq "mhz") {
  704. printf FD "$value\t$info[3] $info[$#info]$fill\n";
  705. } else {
  706. die "Unknown units: $units";
  707. }
  708. }
  709. if ($slide) {
  710. print FD "%Title n $title\n";
  711. print FD "%ps 12\n";
  712. print FD "%ft HB\n";
  713. } else {
  714. print FD "%Title n $title\n";
  715. print FD "%Title s lmbench v1.1\n";
  716. print FD "%ps 16\n";
  717. print FD "%ft R\n";
  718. }
  719. close(FD);
  720. }
  721. # Try and create sensible names from uname -a output
  722. sub getinfo
  723. {
  724. local(@info);
  725. local($name);
  726. local($mhz) = $_[1];
  727. $mhz =~ s/[\. ].*//;
  728. @info = split(/\s+/, $_[0]);
  729. $name = pop(@info);
  730. chop($name);
  731. if ($name eq "mips") {
  732. $name = "$info[$#info]@$mhz";
  733. } elsif ($_[0] =~ /HP-UX/) {
  734. $name = "$info[7]@$mhz";
  735. } elsif ($_[0] =~ /SunOS/) {
  736. $name = "$info[7]@$mhz";
  737. } elsif ($_[0] =~ /AIX/) {
  738. $name = "$name@$mhz";
  739. } else {
  740. $name .= "@$mhz";
  741. }
  742. push(@info, $name);
  743. @info;
  744. }
  745. # Return true if the values differe by less than 10%
  746. sub same
  747. {
  748. local($a, $b) = @_;
  749. if ($a > $b) {
  750. $percent = (($a - $b) / $a) * 100;
  751. } else {
  752. $percent = (($b - $a) / $b) * 100;
  753. }
  754. return ($percent <= 20);
  755. }
  756. # Try and create sensible names from uname -a output
  757. sub getos
  758. {
  759. local(@info);
  760. @info = split(/\s+/, $_[0]);
  761. $info[5] =~ s/-.*//;
  762. "$info[3] $info[5]";
  763. }