Chromium Code Reviews| 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..59c3e1e301ebeaa267abb54bfbbe9d3124141ab8 |
| --- /dev/null |
| +++ b/tools/perf/profile_creators/profile_safe_url_list.py |
| @@ -0,0 +1,22 @@ |
| +# 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 |
| + |
|
dtu
2015/02/12 23:46:12
style guide nit: 2 blank spaces between top level
erikchen
2015/02/13 03:58:58
Done.
|
| +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") |
| + json_data = open(safe_url_path).read() |
| + return json.loads(json_data) |
|
dtu
2015/02/12 23:46:12
To ensure prompt file closing (otherwise file is c
erikchen
2015/02/13 03:58:58
Ah, good point.
|