convert analyzer to function, add batch processing, bug fixing
This commit is contained in:
parent
ffa270c0b0
commit
ebe17c1762
|
|
@ -37,7 +37,7 @@
|
||||||
<ConfirmationsSetting value="0" id="Add" />
|
<ConfirmationsSetting value="0" id="Add" />
|
||||||
<ConfirmationsSetting value="0" id="Remove" />
|
<ConfirmationsSetting value="0" id="Remove" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|
|
||||||
|
|
@ -34,26 +34,13 @@ def checkFiles(folderpath, timestamp):
|
||||||
return status
|
return status
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
def analyzeit(logger, folder, myAnalyzer, remoteIP, sizeOptions=[None]):
|
||||||
DEBUG = True
|
|
||||||
logger = EmptyLogger("App", isDebugging=DEBUG, printout=True)
|
|
||||||
# remoteIP = '128.111.68.220'
|
|
||||||
remoteIP = '192.168.2.1'
|
|
||||||
# sizeOptions = [1, 5, 10, 20, 50, 100] # MB
|
|
||||||
sizeOptions = [None] # MB
|
|
||||||
# folder = sys.argv[1]
|
|
||||||
# folder = './models/bypass/120MBps/'
|
|
||||||
folder = '/Users/yanzi/GDrive/UCSB/Projects/Offloading_2017/Data/' +\
|
|
||||||
'initial_comparison/udp_mtu20k/160Mbps'
|
|
||||||
# check if is folder
|
# check if is folder
|
||||||
if os.path.isdir(folder):
|
if os.path.isdir(folder):
|
||||||
files = [x for x in os.listdir(folder) if '.cpuRaw' in x]
|
files = [x for x in os.listdir(folder) if '.cpuRaw' in x]
|
||||||
else:
|
else:
|
||||||
logger.error('{0} does not exist (or is not a folder)'.format(folder))
|
logger.error('{0} does not exist (or is not a folder)'.format(folder))
|
||||||
sys.exit(1)
|
return False
|
||||||
# create analyzer obj
|
|
||||||
myAnalyzer = EnergyAnalyzer(
|
|
||||||
"shamu", isDebugging=DEBUG, unit="mW", output_path=folder)
|
|
||||||
for i in xrange(len(files)):
|
for i in xrange(len(files)):
|
||||||
file = files[i]
|
file = files[i]
|
||||||
logger.debug(file)
|
logger.debug(file)
|
||||||
|
|
@ -72,7 +59,7 @@ if __name__ == "__main__":
|
||||||
# parse wifi
|
# parse wifi
|
||||||
if 'tcpdump' in status:
|
if 'tcpdump' in status:
|
||||||
logger.debug('reading tcpdump...')
|
logger.debug('reading tcpdump...')
|
||||||
if 'bypass' in folder:
|
if 'bypass' in folder or 'RawSocket' in folder:
|
||||||
myfilter = ""
|
myfilter = ""
|
||||||
else:
|
else:
|
||||||
myfilter = "host {0}".format(remoteIP)
|
myfilter = "host {0}".format(remoteIP)
|
||||||
|
|
@ -103,3 +90,21 @@ if __name__ == "__main__":
|
||||||
myAnalyzer.generate_result_summary(
|
myAnalyzer.generate_result_summary(
|
||||||
wifi='tcpdump' in status,
|
wifi='tcpdump' in status,
|
||||||
f_suffix="_{0}".format(i))
|
f_suffix="_{0}".format(i))
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
DEBUG = False
|
||||||
|
logger = EmptyLogger("App", isDebugging=DEBUG, printout=True)
|
||||||
|
# remoteIP = '128.111.68.220'
|
||||||
|
remoteIP = '192.168.2.1'
|
||||||
|
# sizeOptions = [1, 5, 10, 20, 50, 100] # MB
|
||||||
|
sizeOptions = [None] # MB
|
||||||
|
# folder = sys.argv[1]
|
||||||
|
# folder = './models/bypass/120MBps/'
|
||||||
|
folder = '/Users/yanzi/GDrive/UCSB/Projects/Offloading_2017/Data/' +\
|
||||||
|
'bg_measurement_test'
|
||||||
|
# 'initial_comparison/udp_mtu20k/160Mbps'
|
||||||
|
# create analyzer obj
|
||||||
|
myAnalyzer = EnergyAnalyzer(
|
||||||
|
"shamu", isDebugging=DEBUG, unit="mW", output_path=folder)
|
||||||
|
|
||||||
|
analyzeit(logger, folder, myAnalyzer, remoteIP, sizeOptions)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,102 @@
|
||||||
|
import sys
|
||||||
|
import os
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
|
import collections
|
||||||
|
|
||||||
|
from energy_analyzer import *
|
||||||
|
sys.path.append("modules")
|
||||||
|
try:
|
||||||
|
from analyzer import *
|
||||||
|
except:
|
||||||
|
raise
|
||||||
|
|
||||||
|
|
||||||
|
def fetchfile(foldername):
|
||||||
|
subprocess.call(
|
||||||
|
'./pullTarsFromPhone.sh {0}'.format(foldername), shell=True)
|
||||||
|
|
||||||
|
|
||||||
|
def load_folder(
|
||||||
|
mydict,
|
||||||
|
foldername,
|
||||||
|
folderbase):
|
||||||
|
rootfolder = '{0}/{1}'.format(folderbase, foldername)
|
||||||
|
folders = [f for f in os.listdir(rootfolder)
|
||||||
|
if os.path.isdir('{0}/{1}'.format(rootfolder, f))]
|
||||||
|
while len(folders) > 0:
|
||||||
|
folder = folders.pop()
|
||||||
|
folder_path = '{0}/{1}'.format(rootfolder, folder)
|
||||||
|
thrpt_folders = [f for f in os.listdir(folder_path)
|
||||||
|
if os.path.isdir('{0}/{1}'.format(folder_path, f))]
|
||||||
|
for thrpt in thrpt_folders:
|
||||||
|
thrpt_folder_path = '{0}/{1}'.format(folder_path, thrpt)
|
||||||
|
files = [f for f in os.listdir(thrpt_folder_path)
|
||||||
|
if '.tar.gz' in f]
|
||||||
|
mydict[folder][thrpt] = files
|
||||||
|
|
||||||
|
# reorganize files
|
||||||
|
files = os.listdir(rootfolder)
|
||||||
|
files = sorted([file for file in files if '.tar.gz' in file])
|
||||||
|
|
||||||
|
for file in files:
|
||||||
|
# print file
|
||||||
|
tmp = file.split('_')
|
||||||
|
mode = tmp[0]
|
||||||
|
method = '{0}_{1}'.format(tmp[1], tmp[2])
|
||||||
|
filesize = tmp[3]
|
||||||
|
repeats = tmp[4][:-7]
|
||||||
|
thrpt = tmp[6]
|
||||||
|
mydict[method][thrpt].append(file)
|
||||||
|
|
||||||
|
for method in mydict.keys():
|
||||||
|
method_folder = '{0}/{1}'.format(rootfolder, method)
|
||||||
|
if not os.path.isdir(method_folder):
|
||||||
|
os.mkdir(method_folder)
|
||||||
|
for thrpt in mydict[method].keys():
|
||||||
|
thrpt_folder = '{0}/{1}'.format(method_folder, thrpt)
|
||||||
|
if not os.path.isdir(thrpt_folder):
|
||||||
|
os.mkdir(thrpt_folder)
|
||||||
|
subprocess.call('rm {0}/*.csv'.format(thrpt_folder),
|
||||||
|
shell=True)
|
||||||
|
for file in mydict[method][thrpt]:
|
||||||
|
if os.path.isfile('{0}/{1}'.format(rootfolder, file)):
|
||||||
|
subprocess.call(
|
||||||
|
'mv {0}/{1} {2}'.format(
|
||||||
|
rootfolder, file, thrpt_folder),
|
||||||
|
shell=True)
|
||||||
|
subprocess.call(
|
||||||
|
'cd {0} && tar -xzf {0}/{1}'.format(
|
||||||
|
thrpt_folder, file),
|
||||||
|
shell=True)
|
||||||
|
|
||||||
|
# construct dict
|
||||||
|
mydict = collections.defaultdict(lambda: collections.defaultdict(list))
|
||||||
|
|
||||||
|
# folder name
|
||||||
|
foldername = 'low_thrpt_tests'
|
||||||
|
folderbase = '/Users/yanzi/GDrive/UCSB/Projects/Offloading_2017/Data/'
|
||||||
|
|
||||||
|
# get files
|
||||||
|
# fetchfile(foldername)
|
||||||
|
|
||||||
|
# load
|
||||||
|
load_folder(mydict, foldername, folderbase)
|
||||||
|
|
||||||
|
DEBUG = False
|
||||||
|
logger = EmptyLogger("App", isDebugging=DEBUG, printout=True)
|
||||||
|
# remoteIP = '128.111.68.220'
|
||||||
|
remoteIP = '192.168.2.1'
|
||||||
|
# sizeOptions = [1, 5, 10, 20, 50, 100] # MB
|
||||||
|
sizeOptions = [None] # MB
|
||||||
|
|
||||||
|
myAnalyzer = EnergyAnalyzer(
|
||||||
|
"shamu", isDebugging=DEBUG, unit="mW", logger=logger)
|
||||||
|
|
||||||
|
for method in mydict.keys():
|
||||||
|
for thrpt in mydict[method].keys():
|
||||||
|
folder = '{0}/{1}/{2}/{3}'.format(
|
||||||
|
folderbase, foldername, method, thrpt)
|
||||||
|
# analyzer obj
|
||||||
|
myAnalyzer.output_path = folder
|
||||||
|
analyzeit(logger, folder, myAnalyzer, remoteIP, sizeOptions)
|
||||||
|
|
@ -15,7 +15,7 @@ class EnergyAnalyzer():
|
||||||
Energy analyzer
|
Energy analyzer
|
||||||
'''
|
'''
|
||||||
def __init__(self, productname,
|
def __init__(self, productname,
|
||||||
isDebugging=False, unit="mW", output_path=None):
|
isDebugging=False, unit="mW", output_path=None, logger=None):
|
||||||
self.myModel = Model(isDebugging=isDebugging, unit=unit)
|
self.myModel = Model(isDebugging=isDebugging, unit=unit)
|
||||||
self.myModel.load(productname)
|
self.myModel.load(productname)
|
||||||
self.num_of_cores = getCoreNum(productname)
|
self.num_of_cores = getCoreNum(productname)
|
||||||
|
|
@ -26,8 +26,11 @@ class EnergyAnalyzer():
|
||||||
self.output_path = output_path
|
self.output_path = output_path
|
||||||
|
|
||||||
self.DEBUG = isDebugging
|
self.DEBUG = isDebugging
|
||||||
self.logger = EmptyLogger(
|
if logger is None:
|
||||||
"EnergyAnalyzer", isDebugging=self.DEBUG, printout=True)
|
self.logger = EmptyLogger(
|
||||||
|
"EnergyAnalyzer", isDebugging=self.DEBUG, printout=True)
|
||||||
|
else:
|
||||||
|
self.logger = logger
|
||||||
|
|
||||||
'''
|
'''
|
||||||
Variable clean up functions
|
Variable clean up functions
|
||||||
|
|
@ -444,7 +447,7 @@ class EnergyAnalyzer():
|
||||||
while self.wifi_rssi[
|
while self.wifi_rssi[
|
||||||
curRSSI_idx + 1][0] < self.data_tcpdump[i][0]:
|
curRSSI_idx + 1][0] < self.data_tcpdump[i][0]:
|
||||||
curRSSI_idx += 1
|
curRSSI_idx += 1
|
||||||
if curRSSI_idx >= len(self.wifi_rssi):
|
if curRSSI_idx >= len(self.wifi_rssi) - 1:
|
||||||
curRSSI_idx -= 1
|
curRSSI_idx -= 1
|
||||||
break
|
break
|
||||||
curRSSI = self.wifi_rssi[curRSSI_idx][1]
|
curRSSI = self.wifi_rssi[curRSSI_idx][1]
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,8 @@
|
||||||
|
|
||||||
loc=/Users/yanzi/GDrive/UCSB/Projects/Offloading_2017/Data/$1;
|
loc=/Users/yanzi/GDrive/UCSB/Projects/Offloading_2017/Data/$1;
|
||||||
|
|
||||||
|
adb devices
|
||||||
|
|
||||||
if [ ! -d $loc ]; then
|
if [ ! -d $loc ]; then
|
||||||
mkdir -p $loc;
|
mkdir -p $loc;
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue