parse_sizes 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #!/usr/bin/perl
  2. use strict;
  3. my $mode = '';
  4. my $depth = 0;
  5. my $what = '';
  6. my $setupsize = 0;
  7. my $opsize = 0;
  8. while(<>) {
  9. chomp;
  10. if (/===== Running floram (\S+) (\d+)/) {
  11. $mode = $1;
  12. $depth = $2;
  13. $what = '';
  14. $setupsize = 0;
  15. $opsize = 0;
  16. next;
  17. }
  18. if (/ORAM ACCESS \(SETUP/) {
  19. $what = 'SETUP';
  20. next;
  21. }
  22. if (/ORAM ACCESS \(READ|WRITE/) {
  23. $what = 'OP';
  24. next;
  25. }
  26. if (/,8,/) {
  27. my @F = split(/,/);
  28. my @sizes = ();
  29. my $i;
  30. for ($i=4;$i<=$#F;$i+=3) {
  31. push(@sizes, $F[$i]);
  32. }
  33. if ($what eq '') {
  34. die "Unrecognized data line\n";
  35. }
  36. if ($what eq 'SETUP') {
  37. $setupsize += $sizes[0];
  38. } elsif ($#sizes == 0) {
  39. $opsize += 128 * $sizes[0];
  40. } elsif ($#sizes == 1) {
  41. $opsize += $sizes[0] + 127 * $sizes[1];
  42. } elsif ($#sizes == 127) {
  43. foreach (@sizes) { $opsize += $_; }
  44. } else {
  45. die "Bad number of data points\n";
  46. }
  47. }
  48. $what = '';
  49. if (/===== End/) {
  50. # The setupsize and opsize are the _sum_ for the two parties, so
  51. # add them to get the total size for both parties, and divide by
  52. # 2 to get the average size for each party
  53. my $bytes = ($setupsize + $opsize) / 2;
  54. my $kib = $bytes / 1024;
  55. print "$depth $kib\n";
  56. }
  57. }