parameters: (log_file_name, app, time_key, delimiter, index, strip_end, divider, inner_cnt, time_key_own_line)
docstring: @time_key: used to find the time of execution in the log file
      @delimiter: used to extract the time
      @index: used together with the delimiter
      @strip_end: end index to strip off (e.g. seconds) from the time value
      @divider: divice this value to convert the time in log into seconds
      @inner_cnt: number of runs that an application performs internally
      @time_key_own_line: if the time_key is one its own line
function: def parse_result(log_file_name, app, time_key, delimiter, index, strip_end, divider, inner_cnt, time_key_own_line):
      """
      @time_key: used to find the time of execution in the log file
      @delimiter: used to extract the time
      @index: used together with the delimiter
      @strip_end: end index to strip off (e.g. seconds) from the time value
      @divider: divice this value to convert the time in log into seconds
      @inner_cnt: number of runs that an application performs internally
      @time_key_own_line: if the time_key is one its own line
      """
      print ("processing log file: " + log_file_name)
      with open(log_file_name) as f:
          content = f.readlines()
      content = [x.strip() for x in content]
      # if the file is empty, don't try to parse it
      if (len(content) < 3):
          print "invalid log file" + log_file_name
          return -1
      initial_inner_cnt = inner_cnt
      min_time = 10000000
      sum_time = 0
      successes = 1
      for i in range(len(content)):
          line = content[i]
          if line.find("successes") != -1:
              successes = int(line.split("=")[1])
          if line.find(time_key) != -1:
              if time_key_own_line:
                  next_line = content[i+1]
                  time_str = next_line.strip()
              else:
                  time_str = line.split(delimiter)[index]
              if strip_end:
                  time_str = time_str[:strip_end] # strip the (s) at the end
              if time_str.strip() == '':
                  time = min_time
              else:
                  time = float(time_str) / divider 
              if time < min_time:
                  min_time = time
              inner_cnt -= 1
              if inner_cnt == 0 and (app == "bfs" or app == "sssp"):
                  sum_time += min_time
                  min_time = 10000
                  inner_cnt = initial_inner_cnt
      if (app == "pr" or app == "cc" or app == "cf" or app == "prd"):
          return min_time
      else: # bfs or sssp
          return sum_time / successes
function_tokens: def parse_result ( log_file_name , app , time_key , delimiter , index , strip_end , divider , inner_cnt , time_key_own_line ) : print ( "processing log file: " + log_file_name ) with open ( log_file_name ) as f : content = f . readlines ( ) content = [ x . strip ( ) for x in content ] # if the file is empty, don't try to parse it if ( len ( content ) < 3 ) : print "invalid log file" + log_file_name return - 1 initial_inner_cnt = inner_cnt min_time = 10000000 sum_time = 0 successes = 1 for i in range ( len ( content ) ) : line = content [ i ] if line . find ( "successes" ) != - 1 : successes = int ( line . split ( "=" ) [ 1 ] ) if line . find ( time_key ) != - 1 : if time_key_own_line : next_line = content [ i + 1 ] time_str = next_line . strip ( ) else : time_str = line . split ( delimiter ) [ index ] if strip_end : time_str = time_str [ : strip_end ] # strip the (s) at the end if time_str . strip ( ) == '' : time = min_time else : time = float ( time_str ) / divider if time < min_time : min_time = time inner_cnt -= 1 if inner_cnt == 0 and ( app == "bfs" or app == "sssp" ) : sum_time += min_time min_time = 10000 inner_cnt = initial_inner_cnt if ( app == "pr" or app == "cc" or app == "cf" or app == "prd" ) : return min_time else : # bfs or sssp return sum_time / successes