In [25]:
import numpy as np
import re
import time
file1="log12threads.txt"
file2="log4threads.txt"

In [26]:
def convert(string):
    date=string.split(":")
    hours=int(date[0])
    minutes=int(date[1])
    seconds=int(date[2])
    time=3600*hours+60*minutes+seconds
    return time

def div(int1, int2):
    a=float(int1)
    b=float(int2)
    if b==0.0:
        result=0
    elif b==0 and a==0:
        result=0
    else:
        result=int(a/b*100)
    return result

In [40]:
time1=[]
time2=[]
expression1=[]
expression2=[]
time=re.compile('(([0-1]?[0-9])|([2][0-3])):([0-5]?[0-9])(:([0-5]?[0-9]))')
with open(file1,"r") as f: 
    lines=f.readlines()
    for line in lines:
        match=re.search(time,line)
        if match:
            time1.append(convert(match.group(0)))
            expression1.append(line.split(match.group(0))[-1])
            
with open(file2,"r") as f:   
    lines=f.readlines()
    for line in lines:
        match=re.search(time,line)
        if match:
            time2.append(convert(match.group(0)))
            expression2.append(line.split(match.group(0))[-1])

for expression
            
t1=np.array(time1)
t2=np.array(time2)
diff1=np.diff(t1)
diff2=np.diff(t2)

tot1=np.sum(diff1)
tot2=np.sum(diff2)
print "Total Time File1 \"{}\" is {}s".format(file1,tot1)
print "Total Time File2 \"{}\" is {}s".format(file2,tot2)
print " The following steps were made"
print "File 1 |  File 2 |File1/File2[%]|  Action "
for i in range(len(expression)-1):
    if not (diff1[i]==0.0 and diff1[i]==0.0):
        print " {:4}s |   {:4}s |        {:4}% | {}".format(diff1[i],diff2[i],div(diff1[i],diff2[i]),expression1[i+1])


Total Time File1 "log12threads.txt" is 1090s
Total Time File2 "log4threads.txt" is 1852s
 The following steps were made
File 1 |  File 2 |File1/File2[%]|  Action 
   12s |     11s |         109% |  DFT data was created by gaussian

    1s |      2s |          50% |  Calculated exchange-correlation expectation values 

    2s |      4s |          50% |  Smallest eigenvalue of GW Overlap matrix : 9.42112e-05

    4s |     11s |          36% |  Filled GW Coulomb matrix of dimension: 2362

    4s |      9s |          44% |  Prepared GW Coulomb matrix for symmetric PPM 

  113s |    297s |          38% |  Calculated Mmn_beta (3-center-overlap x orbitals)  

   68s |    178s |          38% |  Prepared Mmn_beta for RPA  

   27s |     72s |          37% |  Symmetrize Mmn_beta for RPA  

   60s |    160s |          37% |  Symmetrize Mmn_beta for self-energy  

   55s |    147s |          37% |  Calculated epsilon via RPA  

    3s |      7s |          42% |  Constructed PPM parameters  

   60s |    159s |          37% |  Prepared threecenters for sigma  

  544s |    540s |         100% |  Calculated exchange part of Sigma  

    7s |     16s |          43% |  Calculated correlation part of Sigma  

   45s |    114s |          39% |  Direct part of e-h interaction 

    1s |      1s |         100% |  Free transition part of electron-hole pairs 

   29s |     63s |          46% |  Exchange part of e-h interaction 

   55s |     60s |          91% |  Finished evaluating pair 1:2


In [27]: