summaryrefslogtreecommitdiffstats
path: root/tools/perf/profile_creators/profile_safe_url_list.py
blob: 3bb6cf3d4576065a018a144ac4fa820e0bb72822 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# 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)