Python Prach

You might also like

Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

# importing modules

import os
import re
#function to take time stamp
def take_time_stamps(line):
timestamp = re.search('(?<=C66xx_2\]\[)(\S+) (\S+)(?=\])', line)
#print timestamp
# print "end"
tsc = timestamp.group(0)
#print tsc
tscgroup = re.search('(\d+) (\d+)',tsc)
tscl = int (tscgroup.group(2))
return tscl
#############################################
################################################################################
###########################
def get_decimation_data(main_str,str1,str2):
ptr1=0
count=0
total_cycles_antenna1 = 0
total_cycles_antenna2 = 0
antenna_num1 = 1
antenna_num2 = 2
antenna_idx = 0
sfnumC = 0
sfnum = 0
aif2count = 0
while ptr1 < len(full_file_list):
line = full_file_list[ptr1]
if(line.find("Decimation") >=0):
if (line.find("STARTED") >=0):
antenna_idx = re.search('( Antenna )(\d+)',line)
antenna_idx = int(antenna_idx.group(2))
sf_grp = re.search('(SF:)(\d+)',line)
sfnum = int (sf_grp.group(2))
symb_grp = re.search('(SYM:)(\d+)',line)
symbol = int (symb_grp.group(2))
main_str_start = take_time_stamps(full_file_list[ptr1])
ptr2 = ptr1+1
line = full_file_list[ptr2]
while not (line.find("Decimation") and line.find("COMPLETED")):
if (line.find("AIF2") >=0):
if (line.find("STARTED") >=0):
aif2count = aif2count + 1
ptr2=ptr2+1
if (line.find("COMPLETED") >=0):
sf_grp = re.search('(SF:)(\d+)',line)
sfnumC = int (sf_grp.group(2))
symb_grp = re.search('(SYM:)(\d+)',line)
symbol1 = int (symb_grp.group(2))
if sfnumC == sfnum :
main_str_end = take_time_stamps(full_file_list[ptr1])

diff = main_str_end - main_str_start


total_cycles_antenna1 = diff + total_cycles_antenna1

else:
pass
#count = count+1
#print count
ptr1 = ptr1+1
print "aif2count",aif2count
print "***** Number of cycles(Gross) taken by",main_str,"for antenna",antenn
a_num1,"are",total_cycles_antenna1,"*****"
print "***** Number of cycles(Gross) taken by",main_str,"for antenna",antenn
a_num2,"are",total_cycles_antenna2,"*****"
################################################################################
###########################

##################################### File Related Data ########################


###########################
directory = os.getcwd()
ip_rach_file_path = directory + '/test.txt'
ip_all_core_logs = open(ip_rach_file_path,'r')
op_file_path_after_core2sep = directory + '/jagcore2logs1.txt'
op_core2log_file = open(op_file_path_after_core2sep,'w')
for line in ip_all_core_logs:
if(line.find("PROFILE") >=0):
if (line.find("C66xx_2") >=0):
op_core2log_file.write(line)
else:
pass
op_core2log_file.close()
print '*****Separated Core2Logs*****'
ip_core2_logs = open(op_file_path_after_core2sep,'r')
full_file_list = ip_core2_logs.readlines()
################################################################################
###########################
main_str = "Decimation"
str1 = "STARTED"
str2 = "COMPLETED"
get_decimation_data(main_str,str1,str2)

You might also like