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.
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.
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
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