- add sources.
[platform/framework/web/crosswalk.git] / src / tools / telemetry / telemetry / core / platform / linux_platform_backend.py
1 # Copyright (c) 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.
4
5 import subprocess
6
7 from telemetry.core.platform import posix_platform_backend
8 from telemetry.core.platform import proc_util
9
10
11 class LinuxPlatformBackend(posix_platform_backend.PosixPlatformBackend):
12
13   def StartRawDisplayFrameRateMeasurement(self):
14     raise NotImplementedError()
15
16   def StopRawDisplayFrameRateMeasurement(self):
17     raise NotImplementedError()
18
19   def GetRawDisplayFrameRateMeasurements(self):
20     raise NotImplementedError()
21
22   def IsThermallyThrottled(self):
23     raise NotImplementedError()
24
25   def HasBeenThermallyThrottled(self):
26     raise NotImplementedError()
27
28   def GetSystemCommitCharge(self):
29     meminfo_contents = self._GetFileContents('/proc/meminfo')
30     return proc_util.GetSystemCommitCharge(meminfo_contents)
31
32   def GetCpuStats(self, pid):
33     stats = self._GetFileContents('/proc/%s/stat' % pid).split()
34     return proc_util.GetCpuStats(stats)
35
36   def GetCpuTimestamp(self):
37     timer_list = self._GetFileContents('/proc/timer_list')
38     return proc_util.GetTimestampJiffies(timer_list)
39
40   def GetMemoryStats(self, pid):
41     status = self._GetFileContents('/proc/%s/status' % pid)
42     stats = self._GetFileContents('/proc/%s/stat' % pid).split()
43     return proc_util.GetMemoryStats(status, stats)
44
45   def GetIOStats(self, pid):
46     io_contents = self._GetFileContents('/proc/%s/io' % pid)
47     return proc_util.GetIOStats(io_contents)
48
49   def GetOSName(self):
50     return 'linux'
51
52   def CanFlushIndividualFilesFromSystemCache(self):
53     return True
54
55   def FlushEntireSystemCache(self):
56     p = subprocess.Popen(['/sbin/sysctl', '-w', 'vm.drop_caches=3'])
57     p.wait()
58     assert p.returncode == 0, 'Failed to flush system cache'