| 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..94af22e139bf7c094a206eb9b2de5b04416544fe
|
| --- /dev/null
|
| +++ b/tools/telemetry/telemetry/core/gpu_info.py
|
| @@ -0,0 +1,90 @@
|
| +# 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:
|
| +
|
| + gpu (of type GPUDevice): the primary GPU on the system.
|
| + secondary_gpus (array of type GPUDevice): the secondary GPUs,
|
| + if any, on the system. Will be the empty array if none.
|
| + machine_model (of type string): a platform-dependent string
|
| + describing the model of machine, or the empty string if not
|
| + supported.
|
| +
|
| + Consult the documentation for the individual properties for
|
| + more details."""
|
| +
|
| + def __init__(self, attrs):
|
| + required_attributes = [
|
| + 'gpu',
|
| + ]
|
| +
|
| + self._gpu = None
|
| + self._secondary_gpus = []
|
| + self._machine_model = ''
|
| + self._optional_attributes = dict()
|
| +
|
| + for a in required_attributes:
|
| + if not a in attrs:
|
| + raise Exception('Missing required attribute "%s" in dictionary' % a)
|
| +
|
| + for k, v in attrs.iteritems():
|
| + if k == 'gpu':
|
| + self._gpu = gpu_device.GPUDevice.FromDict(v)
|
| + elif k == 'secondary_gpus':
|
| + self._secondary_gpus = [gpu_device.GPUDevice.FromDict(d) for d in v]
|
| + elif k == 'machine_model':
|
| + self._machine_model = v
|
| + else:
|
| + self._optional_attributes[k] = v
|
| +
|
| + @classmethod
|
| + def FromDict(cls, attrs):
|
| + """Constructs a GPUInfo from a dictionary of attributes.
|
| + Attributes currently required to be present in the dictionary:
|
| +
|
| + gpu (object containing GPUDevice's required attributes)
|
| + """
|
| + return cls(attrs)
|
| +
|
| + @property
|
| + def gpu(self):
|
| + "The GPUDevice corresponding to the primary GPU on the system."
|
| + return self._gpu
|
| +
|
| + @property
|
| + def secondary_gpus(self):
|
| + "An array of GPUDevices corresponding to any secondary GPUs on the system."
|
| + return self._secondary_gpus
|
| +
|
| + @property
|
| + def machine_model(self):
|
| + """A string describing the machine model.
|
| +
|
| + This is a highly platform-dependent value and not currently
|
| + specified for any machine type aside from Macs. On Mac OS,
|
| + this is the model identifier, for example 'MacBookPro10,1'."""
|
| + return self._machine_model
|
| +
|
| + @property
|
| + def optional_attributes(self):
|
| + """Returns a dictionary of 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._optional_attributes
|
|
|