1"""Utility functions for the memory tests. 2""" 3 4from datetime import datetime 5 6 7def compute_total_diff(line, base_time): 8 """ 9 Computes the difference in time the line was recorded from the base time. 10 11 An example of a line is: 12 [4688:4688:0701/010151:ERROR:perf_provider_chromeos.cc(228)]... 13 14 Here, the month is 07, the day is 01 and the time is 01:01:51. 15 16 line- the line that contains the time the record was taken 17 base_time- the base time to measure our timestamp from 18 """ 19 date = line.strip().split(':')[2].split('/') 20 timestamp = datetime(2014, int(date[0][0:2]), int(date[0][2:4]), 21 int(date[1][0:2]), int(date[1][2:4]), int(date[1][4:6])) 22 return (timestamp - base_time).total_seconds() 23