parse_logs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/usr/bin/perl
  2. # Parse the log output files of run-experiment
  3. # Send concatenated log files to stdin, or list them on the command
  4. # line.
  5. use strict;
  6. my $mode = '';
  7. my $depth = 0;
  8. my $numops = 0;
  9. my $who = 0;
  10. my $what = '';
  11. my $setupsize = 0;
  12. my $opsize = 0;
  13. my @seconds = (0, 0);
  14. my $netsetup = '';
  15. while(<>) {
  16. chomp;
  17. if (/Network setup: (.*)/) {
  18. $netsetup = "$1 ";
  19. next;
  20. }
  21. if (/===== Running floram (\S+) (\d+) (\d+)/) {
  22. $mode = $1;
  23. $depth = $2;
  24. $numops = $3;
  25. @seconds = (0,0);
  26. $what = '';
  27. $setupsize = 0;
  28. $opsize = 0;
  29. next;
  30. }
  31. if (/===== P([01]) output/) {
  32. $who = $1;
  33. next;
  34. }
  35. if (/ORAM ACCESS \(SETUP/) {
  36. $what = 'SETUP';
  37. next;
  38. }
  39. if (/ORAM ACCESS \(READ|WRITE/) {
  40. $what = 'OP';
  41. next;
  42. }
  43. if (/Total time: (\d+\.?\d*) s/) {
  44. $seconds[$who] = $1;
  45. next;
  46. }
  47. if (/^\d+,8,/) {
  48. my @F = split(/,/);
  49. my @sizes = ();
  50. my $i;
  51. for ($i=4;$i<=$#F;$i+=3) {
  52. push(@sizes, $F[$i]);
  53. }
  54. if ($what eq '') {
  55. die "Unrecognized data line\n";
  56. }
  57. if ($what eq 'SETUP') {
  58. $setupsize += $sizes[0];
  59. } else {
  60. foreach (@sizes) { $opsize += $_; }
  61. }
  62. }
  63. $what = '';
  64. if (/===== End/) {
  65. my $maxsecs = $seconds[0];
  66. $maxsecs = $seconds[1] if $seconds[1] > $maxsecs;
  67. print "Floram $mode $depth $netsetup$numops $maxsecs s\n";
  68. # The setupsize and opsize are the _sum_ for the two parties, so
  69. # add them to get the total size for both parties, and divide by
  70. # 2 to get the average size for each party
  71. my $bytes = ($setupsize + $opsize) / 2;
  72. my $kib = $bytes / 1024;
  73. print "Floram $mode $depth $netsetup$numops $kib KiB\n";
  74. }
  75. }