Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Unified Diff: tools/perf/profile_creators/history_profile_extender.py

Issue 914253005: Telemetry: Create new profile creator large_profile_creator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase against top of tree. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/perf/profile_creators/history_profile_extender.py
diff --git a/tools/perf/profile_creators/history_profile_extender.py b/tools/perf/profile_creators/history_profile_extender.py
new file mode 100644
index 0000000000000000000000000000000000000000..5319be4424d0f3a8ce8fd591b6f93f4e7ef6620f
--- /dev/null
+++ b/tools/perf/profile_creators/history_profile_extender.py
@@ -0,0 +1,80 @@
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+import tempfile
+import os
+
+from profile_creators import fast_navigation_profile_extender
+
+
+class HistoryProfileExtender(
+ fast_navigation_profile_extender.FastNavigationProfileExtender):
+ """This extender navigates Chrome to a large number of URIs pointing to local
+ files. It continues running until the history DB becomes full."""
+ _HISTORY_DB_MAX_SIZE_IN_MB = 10
+
+ def __init__(self):
+ super(HistoryProfileExtender, self).__init__()
+
+ # A list of paths of temporary files. The instance is responsible for
+ # making sure that the files are deleted before they are removed from this
+ # list.
+ self._file_paths = []
+
+ def GetUrlsToNavigate(self, maximum_batch_size):
+ """Superclass override.
+
+ This method makes temporary files. It returns URIs to these files, which
+ allows Chrome to populate its history database by navigating to these files
+ on the local file system.
+
+ This method fills the member |_file_paths| with the absolute paths of the
+ temporary files, which must be removed at a later point in time.
+ """
+ urls = []
+ for _ in range(maximum_batch_size):
+ suffix = "reallylongsuffixintendedtoartificiallyincreasethelengthoftheurl"
+ handle, path = tempfile.mkstemp(suffix=suffix)
+ os.close(handle)
+ self._file_paths.append(path)
+
+ file_url = "file://" + path
+ urls.append(file_url)
+
+ return urls
+
+ def ShouldExit(self):
+ """Superclass override."""
+ return self._IsHistoryDBAtMaxSize()
+
+ def NumTabs(self):
+ """Superclass override.
+
+ Navigating to local files is really fast, so the batch size should be extra
+ large.
+ """
+ return super(HistoryProfileExtender, self).NumTabs() * 4
+
+ def TearDown(self):
+ """Superclass override."""
+ super(HistoryProfileExtender, self).TearDown()
+ for path in self._file_paths:
+ os.remove(path)
+ self._file_paths = []
+
+ def FinishedNavigationOfBatch(self):
+ """Superclass override."""
+ for path in self._file_paths:
+ os.remove(path)
+ self._file_paths = []
+
+ def _IsHistoryDBAtMaxSize(self):
+ """Whether the history DB has reached its maximum size."""
+ history_db_path = os.path.join(self.profile_path, "Default", "History")
+ stat_info = os.stat(history_db_path)
+ size = stat_info.st_size
+
+ max_size_threshold = 0.95
+ max_size = ((10**6 * HistoryProfileExtender._HISTORY_DB_MAX_SIZE_IN_MB) *
+ max_size_threshold)
+ return size > max_size

Powered by Google App Engine
This is Rietveld 408576698