Update sdk/platform-tools to version 26.0.0.
[android_tools.git] / sdk / platform-tools / systrace / catapult / telemetry / telemetry / util / bot_utils.py
blob70955f5d3a4ab2e443df261d0c0c7d5ef9a2f7d2
1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
5 """
6 Utility functions used to generate info used by the bots.
8 TODO(eyaich): Remove once we no longer generate the list of benchmarks to
9 run on the perf waterfall in telemetry.
10 """
12 import hashlib
14 def GetDeviceAffinity(num_shards, base_name):
15 # Based on the current timings, we shift the result of the hash function to
16 # achieve better load balancing. Those shift values are to be revised when
17 # necessary. The shift value is calculated such that the total cycle time
18 # is minimized.
19 hash_shift = {
20 2 : 47, # for old desktop configurations with 2 slaves
21 5 : 56, # for new desktop configurations with 5 slaves
22 21 : 43 # for Android 3 slaves 7 devices configurations
24 shift = hash_shift.get(num_shards, 0)
25 base_name_hash = hashlib.sha1(base_name).hexdigest()
26 device_affinity = (int(base_name_hash, 16) >> shift) % num_shards
27 return device_affinity