| Index: tools/telemetry/telemetry/core/gpu_info.py
|
| diff --git a/tools/telemetry/telemetry/core/gpu_info.py b/tools/telemetry/telemetry/core/gpu_info.py
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..38fdb842ee3b0c22d6b016ed8a206f1b36505670
|
| --- /dev/null
|
| +++ b/tools/telemetry/telemetry/core/gpu_info.py
|
| @@ -0,0 +1,58 @@
|
| +# Copyright (c) 2013 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.
|
| +from telemetry.core import gpu_device
|
| +
|
| +class GPUInfo(object):
|
| + """Provides information about the GPUs on the system.
|
| +
|
| + This class guarantees the following properties to be available:
|
| +
|
| + gpus (array of type GPUDevice): the GPUs on the system. Element
|
| + 0 is the primary GPU.
|
| +
|
| + Consult the documentation for the individual properties for
|
| + more details."""
|
| +
|
| + def __init__(self, gpus_array, aux_attributes):
|
| + if gpus_array == None:
|
| + raise Exception("Missing required 'gpus' property")
|
| + if len(gpus_array) == 0:
|
| + raise Exception("Missing at least one GPU in gpus_array")
|
| +
|
| + self._gpus = [gpu_device.GPUDevice.FromDict(d) for d in gpus_array]
|
| + self._aux_attributes = aux_attributes
|
| +
|
| + @classmethod
|
| + def FromDict(cls, attrs):
|
| + """Constructs a GPUInfo from a dictionary of attributes.
|
| + Attributes currently required to be present in the dictionary:
|
| +
|
| + gpus (array of dictionaries, each of which contains
|
| + GPUDevice's required attributes)
|
| + """
|
| + return cls(attrs["gpus"], attrs.get("aux_attributes"))
|
| +
|
| + @property
|
| + def gpus(self):
|
| + "An array of GPUDevices. Element 0 is the primary GPU on the system."
|
| + return self._gpus
|
| +
|
| + @property
|
| + def aux_attributes(self):
|
| + """Returns a dictionary of auxiliary, optional, attributes. On the
|
| + Chrome browser, for example, this dictionary contains:
|
| +
|
| + optimus (boolean)
|
| + amd_switchable (boolean)
|
| + lenovo_dcute (boolean)
|
| + driver_vendor (string)
|
| + driver_version (string)
|
| + driver_date (string)
|
| + gl_version_string (string)
|
| + gl_vendor (string)
|
| + gl_renderer (string)
|
| + gl_extensions (string)
|
| + display_link_version (string)
|
| + """
|
| + return self._aux_attributes
|
|
|