Merge pull request #560 from ifilippov/perf
Supporting perf.py on Mac OS
This commit is contained in:
@@ -73,10 +73,19 @@ def cpu_get():
|
||||
#returns cpu_usage
|
||||
def cpu_check():
|
||||
if is_windows == False:
|
||||
cpu1 = cpu_get()
|
||||
time.sleep(1)
|
||||
cpu2 = cpu_get()
|
||||
cpu_percent = (float(cpu1[0] - cpu2[0])/float(cpu1[1] - cpu2[1]))*100
|
||||
if is_mac == False:
|
||||
cpu1 = cpu_get()
|
||||
time.sleep(1)
|
||||
cpu2 = cpu_get()
|
||||
cpu_percent = (float(cpu1[0] - cpu2[0])/float(cpu1[1] - cpu2[1]))*100
|
||||
else:
|
||||
os.system("sysctl -n vm.loadavg > cpu_temp")
|
||||
c = open("cpu_temp", 'r')
|
||||
c_line = c.readline()
|
||||
c.close
|
||||
os.remove("cpu_temp")
|
||||
R = c_line.split(' ')
|
||||
cpu_percent = float(R[1]) * 3
|
||||
else:
|
||||
os.system("wmic cpu get loadpercentage /value > cpu_temp")
|
||||
c = open("cpu_temp", 'r')
|
||||
@@ -143,6 +152,8 @@ parser.add_option('-p', '--path', dest='path',
|
||||
global is_windows
|
||||
is_windows = (platform.system() == 'Windows' or
|
||||
'CYGWIN_NT' in platform.system())
|
||||
global is_mac
|
||||
is_mac = (platform.system() == 'Darwin')
|
||||
|
||||
# save corrent path
|
||||
pwd = os.getcwd()
|
||||
|
||||
Reference in New Issue
Block a user