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.
7 from telemetry.core.platform import posix_platform_backend
8 from telemetry.core.platform import proc_util
11 class LinuxPlatformBackend(posix_platform_backend.PosixPlatformBackend):
13 def StartRawDisplayFrameRateMeasurement(self):
14 raise NotImplementedError()
16 def StopRawDisplayFrameRateMeasurement(self):
17 raise NotImplementedError()
19 def GetRawDisplayFrameRateMeasurements(self):
20 raise NotImplementedError()
22 def IsThermallyThrottled(self):
23 raise NotImplementedError()
25 def HasBeenThermallyThrottled(self):
26 raise NotImplementedError()
28 def GetSystemCommitCharge(self):
29 meminfo_contents = self._GetFileContents('/proc/meminfo')
30 return proc_util.GetSystemCommitCharge(meminfo_contents)
32 def GetCpuStats(self, pid):
33 stats = self._GetFileContents('/proc/%s/stat' % pid).split()
34 return proc_util.GetCpuStats(stats)
36 def GetCpuTimestamp(self):
37 timer_list = self._GetFileContents('/proc/timer_list')
38 return proc_util.GetTimestampJiffies(timer_list)
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)
45 def GetIOStats(self, pid):
46 io_contents = self._GetFileContents('/proc/%s/io' % pid)
47 return proc_util.GetIOStats(io_contents)
52 def CanFlushIndividualFilesFromSystemCache(self):
55 def FlushEntireSystemCache(self):
56 p = subprocess.Popen(['/sbin/sysctl', '-w', 'vm.drop_caches=3'])
58 assert p.returncode == 0, 'Failed to flush system cache'