bench_oram.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. --- bench_oram_read.oc.orig 2018-02-19 19:03:45.000000000 -0500
  2. +++ bench_oram_read.oc 2023-02-06 08:16:10.000000000 -0500
  3. @@ -79,8 +79,8 @@
  4. }
  5. } else if (arg == 'i') {
  6. samples = atoi(optarg);
  7. - if (samples <= 0) {
  8. - fprintf (stderr, "Argument for -%c must be positive.\n", arg);
  9. + if (samples < 0) {
  10. + fprintf (stderr, "Argument for -%c must be nonnegative.\n", arg);
  11. return;
  12. }
  13. } else if (arg == '?' || arg == ':') {
  14. @@ -96,10 +96,6 @@
  15. }
  16. }
  17. - #ifndef ORAM_PROFILE_SCHEDULING
  18. - fprintf(stdout, "# ORAM ACCESS (READ) (element count, element size, sample 1 microseconds, sample 1 gates, sample 1 bytes, ...)\n");
  19. - #endif
  20. -
  21. OcCopy cpy = ocCopyIntN(elsz);
  22. uint64_t tally = 0;
  23. @@ -107,10 +103,21 @@
  24. uint64_t tallybytes = 0;
  25. obliv uint32_t * output = calloc(1, elsz * sizeof(obliv uint32_t));
  26. + int64_t startuptime = -current_timestamp();
  27. + int64_t startupgates = -yaoGateCount();
  28. + int64_t startupbytes = -tcp2PBytesSent(ocCurrentProto());
  29. oram * o = oram_new(ORAM_TYPE_AUTO, &cpy, elct);
  30. + startuptime += current_timestamp();
  31. + startupgates += yaoGateCount();
  32. + startupbytes += tcp2PBytesSent(ocCurrentProto());
  33. #ifndef ORAM_PROFILE_SCHEDULING
  34. + fprintf(stdout, "# ORAM ACCESS (SETUP) (element count, element size, startup microseconds, startup gates, startup bytes)\n");
  35. fprintf(stdout, "%lld,%lld", elct, elsz);
  36. + fprintf(stdout, ",%llu,%llu,%llu\n", startuptime,startupgates,startupbytes);
  37. + fprintf(stdout, "# ORAM ACCESS (READ) (element count, element size, sample 1 microseconds, sample 1 gates, sample 1 bytes, ...)\n");
  38. + fprintf(stdout, "%lld,%lld", elct, elsz);
  39. + fflush(stdout);
  40. #endif
  41. for (int ii = 0; ii < samples; ii++) {
  42. @@ -137,6 +144,8 @@
  43. #ifndef ORAM_PROFILE_SCHEDULING
  44. fprintf(stdout, "\n");
  45. #endif
  46. + if (samples > 0) {
  47. fprintf(stderr, "ORAM Read (count:%lld, size: %lld): %llu microseconds avg, %llu gates avg, %llu bytes avg\n", elct, elsz, tally / samples, tallygates/samples, tallybytes/samples);
  48. + }
  49. }
  50. --- bench_oram_write.oc.orig 2018-02-19 19:03:45.000000000 -0500
  51. +++ bench_oram_write.oc 2023-02-06 08:22:19.000000000 -0500
  52. @@ -79,8 +79,8 @@
  53. }
  54. } else if (arg == 'i') {
  55. samples = atoi(optarg);
  56. - if (samples <= 0) {
  57. - fprintf (stderr, "Argument for -%c must be positive.\n", arg);
  58. + if (samples < 0) {
  59. + fprintf (stderr, "Argument for -%c must be nonnegative.\n", arg);
  60. return;
  61. }
  62. } else if (arg == '?' || arg == ':') {
  63. @@ -96,10 +96,6 @@
  64. }
  65. }
  66. - #ifndef ORAM_PROFILE_SCHEDULING
  67. - fprintf(stdout, "# ORAM ACCESS (WRITE) (element count, element size, sample 1 microseconds, sample 1 gates, sample 1 bytes, ...)\n");
  68. - #endif
  69. -
  70. OcCopy cpy = ocCopyIntN(elsz);
  71. uint64_t tally = 0;
  72. @@ -107,10 +103,21 @@
  73. uint64_t tallybytes = 0;
  74. obliv uint32_t * input = calloc(1, elsz * sizeof(obliv uint32_t));
  75. + int64_t startuptime = -current_timestamp();
  76. + int64_t startupgates = -yaoGateCount();
  77. + int64_t startupbytes = -tcp2PBytesSent(ocCurrentProto());
  78. oram * o = oram_new(ORAM_TYPE_AUTO, &cpy, elct);
  79. + startuptime += current_timestamp();
  80. + startupgates += yaoGateCount();
  81. + startupbytes += tcp2PBytesSent(ocCurrentProto());
  82. #ifndef ORAM_PROFILE_SCHEDULING
  83. + fprintf(stdout, "# ORAM ACCESS (SETUP) (element count, element size, startup microseconds, startup gates, startup bytes)\n");
  84. fprintf(stdout, "%lld,%lld", elct, elsz);
  85. + fprintf(stdout, ",%llu,%llu,%llu\n", startuptime,startupgates,startupbytes);
  86. + fprintf(stdout, "# ORAM ACCESS (WRITE) (element count, element size, sample 1 microseconds, sample 1 gates, sample 1 bytes, ...)\n");
  87. + fprintf(stdout, "%lld,%lld", elct, elsz);
  88. + fflush(stdout);
  89. #endif
  90. for (int ii = 0; ii < samples; ii++) {
  91. @@ -138,6 +145,8 @@
  92. #ifndef ORAM_PROFILE_SCHEDULING
  93. fprintf(stdout, "\n");
  94. #endif
  95. + if (samples > 0) {
  96. fprintf(stderr, "ORAM Write (count:%lld, size: %lld): %llu microseconds avg, %llu gates avg, %llu bytes avg\n", elct, elsz, tally / samples, tallygates/samples, tallybytes/samples);
  97. + }
  98. }