#!/usr/bin/python
# -*- coding: utf-8 -*
import sys
import os

prefixes = [
  'LF_CR', 'LF_CS', 'LF_I', 'LF_SR', 
  'LF_SS', 'LF_WR', 'LF_WS',
  'DF_CS', 'DF_SS', 'DF_WS', 'DF_I'
]
sufixes = [
  '_1.out', '_2.out', '_3.out', '_4.out'
]

def getTime(line):
  start = line.find('(') + 1
  end = line.find(' ', start)
  return float(line[start:end])

for pref in prefixes:
  out = pref
  for suf in sufixes:
    file_name = pref + suf
    with open(file_name, 'r') as fd:
      # collect times in log file
      time = 0.0
      for line in fd.readlines():
        # target line is like:
        #   ... (x.xx seconds)
        if line.find(' seconds)') >= 0:
          time += getTime(line)
      out += ', ' + str(round(time,3))
      fd.close()
  print(out)
