parse_logs 1.8 KB

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