Skip to content

Commit

Permalink
#221 Dumping of Per worker results
Browse files Browse the repository at this point in the history
  • Loading branch information
liyuanwa authored and ywang19 committed Jan 27, 2016
1 parent c4d1826 commit 8d5de58
Show file tree
Hide file tree
Showing 12 changed files with 213 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,13 +94,31 @@ private void doArchive(WorkloadInfo info, File runDir) throws IOException {
exportScriptsLog(info, runDir);
exportPerformanceMatrix(info);
exportTaskInfo(info,runDir);
exportWorkerInfo(info,runDir);
}

private void exportWorkerInfo(WorkloadInfo info,File parent)throws IOException{
for(StageInfo sInfo :info.getStageInfos()){
File file = new File(parent,getStageFileName(sInfo) +"-worker"+ ".csv");
Writer writer = new BufferedWriter(new FileWriter(file));
WorkerExporter exporter = Exporters.newWorkExporter(sInfo);
try {
exporter.export(writer);
} finally {
writer.close();
}
String name = sInfo.getId()+"worker";
String path = file.getAbsolutePath();
String msg = "perf details of {} has been exported to {}";
LOGGER.debug(msg, name, path);
}
}

private void exportTaskInfo(WorkloadInfo info,File parent)throws IOException{
for(DriverInfo dInfo:info.getDriverInfos()){
File file = new File(parent, dInfo.getName() + ".csv");
Writer writer = new BufferedWriter(new FileWriter(file));
TaskExporter exporter = Exporters.newTaskExporter(info,dInfo);
TaskExporter exporter = Exporters.newTaskExporter(info,dInfo);
try {
exporter.export(writer);
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package com.intel.cosbench.controller.model;

import java.awt.List;
import java.util.ArrayList;
import java.util.HashMap;

import org.apache.http.client.HttpClient;
Expand Down Expand Up @@ -46,9 +48,18 @@ public class TaskContext implements TaskInfo {

/* Each task starts with an empty error statistics log*/
private volatile transient HashMap<String, Integer> errorStatistics = new HashMap<String, Integer>();

/*Each task for workers report starts with empty*/
private ArrayList<Metrics> wrReport = new ArrayList<Metrics>();

public TaskContext() {
public ArrayList<Metrics> getWrReport() {
return wrReport;
}

public void setWrReport(ArrayList<Metrics> wrReport) {
this.wrReport = wrReport;
}

public TaskContext() {
/* empty */
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

package com.intel.cosbench.controller.tasklet;

import java.util.List;

import com.intel.cosbench.bench.*;
import com.intel.cosbench.controller.model.TaskContext;
import com.intel.cosbench.protocol.CloseResponse;
Expand Down Expand Up @@ -55,6 +57,9 @@ protected void handleResponse(CloseResponse response) {
context.setLog(response.getDriverLog());
context.setState(response.getState());
context.setErrorStatistics(response.getErrorStatistics());

for(Metrics metrics : response.getWrReport()){
context.getWrReport().add(metrics);
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
package com.intel.cosbench.exporter;

import java.io.IOException;
import java.io.Writer;
import java.util.ArrayList;
import java.util.List;

import com.intel.cosbench.bench.Metrics;
import com.intel.cosbench.bench.Report;
import com.intel.cosbench.bench.TaskReport;
import com.intel.cosbench.model.DriverInfo;
import com.intel.cosbench.model.StageInfo;
import com.intel.cosbench.model.TaskInfo;
import com.intel.cosbench.model.WorkloadInfo;

public abstract class AbstractWorkerExporter implements WorkerExporter {

private StageInfo stageInfo;

public StageInfo getStageInfo() {
return stageInfo;
}

public void setStageInfo(StageInfo stageInfo) {
this.stageInfo = stageInfo;
}

@Override
public void export(Writer writer) throws IOException {
writeReport(writer);
}

private void writeReport(Writer writer) throws IOException {
writeHeader(writer);
writer.flush();
for(TaskInfo taskInfo : stageInfo.getTaskInfos()){
for(Metrics metrics: taskInfo.getWrReport()){
writeMetrics(writer,metrics);
}
}
writer.flush();
}

protected abstract void writeHeader(Writer writer) throws IOException;

protected abstract void writeMetrics(Writer writer, Metrics metrics)
throws IOException;

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package com.intel.cosbench.exporter;

import static com.intel.cosbench.exporter.Formats.NUM;
import static com.intel.cosbench.exporter.Formats.RATIO;

import java.io.IOException;
import java.io.Writer;

import com.intel.cosbench.bench.Metrics;
import com.intel.cosbench.bench.Report;
import com.intel.cosbench.bench.TaskReport;

public class CSVWorkerExporter extends AbstractWorkerExporter{

@Override
protected void writeHeader(Writer writer) throws IOException {
StringBuilder buffer = new StringBuilder();
char[] cs = new char[8];
buffer.append("Op-Type").append(',');
buffer.append("Sample-Type").append(',');
buffer.append("Op-Count").append(',');
buffer.append("Byte-Count").append(',');
buffer.append("Avg-ResTime").append(',');
buffer.append("Avg-ProcTime").append(',');
buffer.append("Throughput").append(',');
buffer.append("Bandwidth").append(',');
buffer.append("Succ-Ratio").append('\n');
writer.write(buffer.toString());
}

@Override
protected void writeMetrics(Writer writer,Metrics metrics)throws IOException {
StringBuilder buffer = new StringBuilder();
/*Operation Type*/
buffer.append(metrics.getOpType()).append(',');
/*sample Type*/
buffer.append(metrics.getSampleType()).append(',');
/* Operation Count */
buffer.append(metrics.getSampleCount()).append(',');
/* Byte Count */
buffer.append(metrics.getByteCount()).append(',');
/* Response Time */
double r = metrics.getAvgResTime();
if (r > 0)
buffer.append(NUM.format(r));
else
buffer.append("N/A");
buffer.append(',');

/* Transfer Time */
double pt = metrics.getAvgResTime() - metrics.getAvgXferTime();
if (pt > 0)
buffer.append(NUM.format(pt));
else
buffer.append("N/A");
buffer.append(',');

/* Throughput */
buffer.append(NUM.format(metrics.getThroughput())).append(',');
/* Bandwidth */
buffer.append(NUM.format(metrics.getBandwidth())).append(',');
/* Success Ratio */
double t = (double) metrics.getRatio();
if (t > 0)
buffer.append(RATIO.format(metrics.getRatio()));
else
buffer.append("N/A");
buffer.append('\n');
writer.write(buffer.toString());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@
*/
public class Exporters {

public static WorkerExporter newWorkExporter(StageInfo info){
AbstractWorkerExporter exporter = new CSVWorkerExporter();
exporter.setStageInfo(info);
return exporter;
}

public static TaskExporter newTaskExporter(WorkloadInfo workloadInfo,DriverInfo driverInfo){
AbstractTaskExporter exporter = new CSVTaskExporter();
exporter.setWorkloadInfo(workloadInfo);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package com.intel.cosbench.exporter;

import java.io.IOException;
import java.io.Writer;

public interface WorkerExporter {
public void export(Writer writer) throws IOException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@
package com.intel.cosbench.model;

import java.util.Date;
import java.util.List;

import com.intel.cosbench.bench.Benchmark;
import com.intel.cosbench.bench.ErrorStatistics;
import com.intel.cosbench.bench.Report;
import com.intel.cosbench.config.Mission;
import com.intel.cosbench.log.LogManager;

Expand All @@ -43,5 +45,7 @@ public interface MissionInfo extends LifeCycle, Benchmark {
public WorkerInfo[] getWorkerInfos();

public ErrorStatistics getErrorStatistics();


public List<Report> getWorkerReports();

}
5 changes: 5 additions & 0 deletions dev/cosbench-core/src/com/intel/cosbench/model/TaskInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

package com.intel.cosbench.model;

import java.util.ArrayList;

import com.intel.cosbench.bench.Benchmark;
import com.intel.cosbench.bench.Metrics;

public interface TaskInfo extends LifeCycle, Benchmark {

Expand All @@ -30,5 +33,7 @@ public interface TaskInfo extends LifeCycle, Benchmark {
public ScheduleInfo getSchedule();

public String getLog();

public ArrayList<Metrics> getWrReport();

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@

package com.intel.cosbench.protocol;

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

import com.intel.cosbench.bench.Metrics;
import com.intel.cosbench.bench.Report;
import com.intel.cosbench.model.TaskState;

/**
Expand All @@ -35,8 +37,17 @@ public class CloseResponse extends Response {
private String driverLog; /* driver log */
private TaskState state;
private HashMap<String, Integer> errorStatistics; /* mission error statistics*/
private List<Metrics> wrReport;

public CloseResponse() {
public List<Metrics> getWrReport() {
return wrReport;
}

public void setWrReport(List<Metrics> wrReport) {
this.wrReport = wrReport;
}

public CloseResponse() {
/* empty */
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,12 @@
import static com.intel.cosbench.model.MissionState.FAILED;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import com.intel.cosbench.bench.Metrics;
import com.intel.cosbench.bench.Report;
import com.intel.cosbench.model.MissionInfo;
import com.intel.cosbench.model.TaskState;
Expand All @@ -43,6 +46,13 @@ protected Response process(MissionInfo info) {
private Response getResponse(MissionInfo info) {
CloseResponse response = new CloseResponse();
Report report = info.getReport();
List<Metrics> wrReport = new ArrayList<Metrics>();
for(Report wReport:info.getWorkerReports()){
for(Metrics metrics : wReport){
wrReport.add(metrics);
}
}
response.setWrReport(wrReport);
response.setReport(Arrays.asList(report.getAllMetrics()));
if (info.getState().equals(FAILED))
response.setState(TaskState.FAILED);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,14 @@ public class MissionContext implements MissionInfo {
private static final String GENERATE_HISTOGRAM_KEY = "histogram";
private static final boolean DEFAULT_GENERATE_HISTOGRAM = true;

public List<Report> getWorkerReports(){
List<Report> wReports = new ArrayList<Report>();
for(WorkerContext wContext:workerRegistry){
wReports.add(wContext.getReport());
}
return wReports;
}

public MissionContext() {
errorStatistics = new ErrorStatistics();
}
Expand Down Expand Up @@ -159,8 +167,6 @@ public void setLogManager(LogManager logManager) {
this.logManager = logManager;
}



public ErrorStatistics getErrorStatistics() {
return errorStatistics;
}
Expand Down

0 comments on commit 8d5de58

Please sign in to comment.