package org.spbu.benchmark.web;

import java.util.ArrayList;
import java.util.List;

import org.spbu.benchmark.ActionResult;
import org.spbu.benchmark.ScenarioResult;

public class HttpScenarioResult implements ScenarioResult {
	private List<ActionResult> actionResults;
	private long time;
	private boolean successful;
	private long average;
	public HttpScenarioResult(List<ActionResult> actionResults, boolean successful, long time){
		this.successful = successful;
		this.actionResults =  actionResults;
		this.time = time;
		long sum = 0;
		for(ActionResult result : actionResults){
			sum += result.getTime();
		}
		if(actionResults.size()!=0) this.average = sum / actionResults.size(); else average = 0;
	}

	@Override
	public List<ActionResult> getActionResults() {
		return actionResults;
	}
	@Override
	public long getTime() {
		return time;
	}
	@Override
	public boolean isSuccessful() {
		return successful;
	}
	public long getAverage(){
		return average;
	}

}
