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