浏览代码

oram: runtimes reporting in ms

Lennart Braun 2 年之前
父节点
当前提交
a118711a41
共有 2 个文件被更改,包括 30 次插入22 次删除
  1. 14 8
      oram/examples/bench_doram.rs
  2. 16 14
      oram/src/oram.rs

+ 14 - 8
oram/examples/bench_doram.rs

@@ -177,15 +177,21 @@ fn main() {
     }
     let d_accesses = Instant::now() - t_start;
 
-    println!("time init:        {:7.3} s", d_init.as_secs_f64());
-    println!("time preprocess:  {:7.3} s", d_preprocess.as_secs_f64());
     println!(
-        "   per accesses: {:7.3} s",
-        d_preprocess.as_secs_f64() / stash_size as f64
+        "time init:        {:10.3} ms",
+        d_init.as_secs_f64() * 1000.0
     );
     println!(
-        "time accesses:    {:7.3} s{}",
-        d_accesses.as_secs_f64(),
+        "time preprocess:  {:10.3} ms",
+        d_preprocess.as_secs_f64() * 1000.0
+    );
+    println!(
+        "   per accesses:  {:10.3} ms",
+        d_preprocess.as_secs_f64() * 1000.0 / stash_size as f64
+    );
+    println!(
+        "time accesses:    {:10.3} ms{}",
+        d_accesses.as_secs_f64() * 1000.0,
         if cli.preprocess {
             "  (online only)"
         } else {
@@ -193,8 +199,8 @@ fn main() {
         }
     );
     println!(
-        "   per accesses: {:7.3} s",
-        d_accesses.as_secs_f64() / stash_size as f64
+        "   per accesses:  {:10.3} ms",
+        d_accesses.as_secs_f64() * 1000.0 / stash_size as f64
     );
 
     comm.shutdown();

+ 16 - 14
oram/src/oram.rs

@@ -119,33 +119,33 @@ impl Runtimes {
         );
         println!("- times per access over {num_accesses} accesses in total");
         println!(
-            "{:30}    {:.5} s",
+            "{:30}    {:7.3} ms",
             ProtocolStep::Preprocess,
-            self.get(ProtocolStep::Preprocess).as_secs_f64() / num_accesses as f64
+            self.get(ProtocolStep::Preprocess).as_secs_f64() * 1000.0 / num_accesses as f64
         );
         for step in ProtocolStep::iter()
             .filter(|x| x.to_string().starts_with("Preprocess") && *x != ProtocolStep::Preprocess)
         {
             println!(
-                "    {:26}    {:.5} s",
+                "    {:26}    {:7.3} ms",
                 step,
-                self.get(step).as_secs_f64() / num_accesses as f64
+                self.get(step).as_secs_f64() * 1000.0 / num_accesses as f64
             );
         }
         for step in ProtocolStep::iter().filter(|x| x.to_string().starts_with("Access")) {
             println!(
-                "{:30}    {:.5} s",
+                "{:30}    {:7.3} ms",
                 step,
-                self.get(step).as_secs_f64() / num_accesses as f64
+                self.get(step).as_secs_f64() * 1000.0 / num_accesses as f64
             );
             match step {
                 ProtocolStep::AccessDatabaseRead => {
                     for step in ProtocolStep::iter().filter(|x| x.to_string().starts_with("DbRead"))
                     {
                         println!(
-                            "    {:26}    {:.5} s",
+                            "    {:26}    {:7.3} ms",
                             step,
-                            self.get(step).as_secs_f64() / num_accesses as f64
+                            self.get(step).as_secs_f64() * 1000.0 / num_accesses as f64
                         );
                     }
                 }
@@ -154,9 +154,9 @@ impl Runtimes {
                         x.to_string().starts_with("DbWrite") || x.to_string().starts_with("Refresh")
                     }) {
                         println!(
-                            "    {:26}    {:.5} s",
+                            "    {:26}    {:7.3} ms",
                             step,
-                            self.get(step).as_secs_f64() / num_accesses as f64
+                            self.get(step).as_secs_f64() * 1000.0 / num_accesses as f64
                         );
                     }
                 }
@@ -165,9 +165,10 @@ impl Runtimes {
                         StashProtocolStep::iter().filter(|x| x.to_string().starts_with("Read"))
                     {
                         println!(
-                            "    {:26}    {:.5} s",
+                            "    {:26}    {:7.3} ms",
                             step,
-                            self.stash_runtimes.get(step).as_secs_f64() / num_accesses as f64
+                            self.stash_runtimes.get(step).as_secs_f64() * 1000.0
+                                / num_accesses as f64
                         );
                     }
                 }
@@ -176,9 +177,10 @@ impl Runtimes {
                         StashProtocolStep::iter().filter(|x| x.to_string().starts_with("Write"))
                     {
                         println!(
-                            "    {:26}    {:.5} s",
+                            "    {:26}    {:7.3} ms",
                             step,
-                            self.stash_runtimes.get(step).as_secs_f64() / num_accesses as f64
+                            self.stash_runtimes.get(step).as_secs_f64() * 1000.0
+                                / num_accesses as f64
                         );
                     }
                 }