package de.lcag.common;

import java.time.Instant;

public class RuntimeTable extends CsvTable {
	private Instant startTime = Instant.now();
	
	public RuntimeTable(String aFilePath) {
		super(aFilePath);

		this.addColumns("StartTime", "Duration", "Comment");
	}
	
	public void addRecord(String aComment) {
		int rowNo = this.lenght() + 1;
		Instant endTime = Instant.now();
		Long duration = endTime.toEpochMilli() - this.startTime.toEpochMilli();

		this.setCellValue(rowNo, "StartTime", startTime);
		this.setCellValue(rowNo, "Duration",  duration);
		this.setCellValue(rowNo, "Comment",  aComment);
		
		// Measure next item:
		this.startTime = Instant.now();
	}

}
