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

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

Issue 918893002: telemetry: Create a safe url generator. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from dtu. 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
« no previous file with comments | « tools/perf/profile_creators/profile_safe_url_list.json ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/perf/profile_creators/profile_safe_url_list.py
diff --git a/tools/perf/profile_creators/profile_safe_url_list.py b/tools/perf/profile_creators/profile_safe_url_list.py
new file mode 100644
index 0000000000000000000000000000000000000000..82a287cf9cc43365eabecbcdf2d7540e96a7c5af
--- /dev/null
+++ b/tools/perf/profile_creators/profile_safe_url_list.py
@@ -0,0 +1,24 @@
+# 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 json
+import os
+import random
+
+
+def GetShuffledSafeUrls():
+ """Returns a deterministic shuffling of safe urls. The profile generators
+ access the urls in order, and the urls are grouped by domain. The shuffling
+ reduces the load on external servers."""
+ random.seed(0)
+ url_list_copy = list(_GetSafeUrls())
+ random.shuffle(url_list_copy)
+ return url_list_copy
+
+
+def _GetSafeUrls():
+ """Returns a list of safe urls by loading them from a pre-generated file."""
+ safe_url_dir = os.path.dirname(os.path.realpath(__file__))
+ safe_url_path = os.path.join(safe_url_dir, "profile_safe_url_list.json")
+ with open(safe_url_path, 'r') as safe_url_file:
+ return json.load(safe_url_file)
dtu 2015/02/13 23:00:00 nit: 2 space indent
erikchen 2015/02/13 23:11:24 Done.
« no previous file with comments | « tools/perf/profile_creators/profile_safe_url_list.json ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698