Reviewers: Yang,

Description:
Add flag for printing the time it took to deserialize the snapshot.

BUG=

Please review this at https://codereview.chromium.org/25695002/

SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge

Affected files (+15, -1 lines):
  M src/flag-definitions.h
  M src/snapshot-common.cc


Index: src/flag-definitions.h
diff --git a/src/flag-definitions.h b/src/flag-definitions.h
index f4df2b950d508292d0d18fd30594768e030bda9c..76471715d3b001c7efb69ccd806ec5682fb277fe 100644
--- a/src/flag-definitions.h
+++ b/src/flag-definitions.h
@@ -595,6 +595,11 @@ DEFINE_int(hash_seed,
            "Fixed seed to use to hash property keys (0 means random)"
"(with snapshots this option cannot override the baked-in seed)")

+// snapshot-common.cc
+DEFINE_bool(profile_deserialization,
+            false,
+            "Print the time it takes to deserialize the snapshot.")
+
 // v8.cc
 DEFINE_bool(preemption, false,
             "activate a 100ms timer that switches between V8 threads")
Index: src/snapshot-common.cc
diff --git a/src/snapshot-common.cc b/src/snapshot-common.cc
index 96034e352bc33ebbe8cc1c3b6e5d41667a81f107..4bdf63ceddbf1e1a5670564a7653b50c92d0b5ac 100644
--- a/src/snapshot-common.cc
+++ b/src/snapshot-common.cc
@@ -102,10 +102,19 @@ bool Snapshot::Initialize(const char* snapshot_file) {
     DeleteArray(str);
     return success;
   } else if (size_ > 0) {
+    ElapsedTimer timer;
+    if (FLAG_profile_deserialization) {
+      timer.Start();
+    }
     SnapshotByteSource source(raw_data_, raw_size_);
     Deserializer deserializer(&source);
     ReserveSpaceForLinkedInSnapshot(&deserializer);
-    return V8::Initialize(&deserializer);
+    bool success = V8::Initialize(&deserializer);
+    if (FLAG_profile_deserialization) {
+      double ms = timer.Elapsed().InMillisecondsF();
+      PrintF("[Snapshot loading and deserialization took %0.3f ms]\n", ms);
+    }
+    return success;
   }
   return false;
 }


--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to