Add flag for printing the time it took to deserialize the snapshot.
authorolivf@chromium.org <olivf@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 2 Oct 2013 11:32:19 +0000 (11:32 +0000)
committerolivf@chromium.org <olivf@chromium.org@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Wed, 2 Oct 2013 11:32:19 +0000 (11:32 +0000)
BUG=
R=yangguo@chromium.org

Review URL: https://codereview.chromium.org/25695002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17072 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

src/flag-definitions.h
src/snapshot-common.cc

index b16396ebc78a7acd4ccdb241037644c25476aedc..13f4a0925cffb8a3a9f9472df3232163b86740ff 100644 (file)
@@ -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 96034e352bc33ebbe8cc1c3b6e5d41667a81f107..4bdf63ceddbf1e1a5670564a7653b50c92d0b5ac 100644 (file)
@@ -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;
 }