Skip to content
Snippets Groups Projects
Commit edd37bcf authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

Merge branch 'formatStatistics' into 'master'

Format statistics

See merge request fiji/haas-java-client!3
parents 1bab16c7 c86a3dbf
No related branches found
No related tags found
1 merge request!3Format statistics
......@@ -2,13 +2,13 @@ package cz.it4i.fiji.haas_spim_benchmark.core;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.InvalidPathException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.text.MessageFormat;
import java.util.Arrays;
import java.util.Collection;
import java.util.LinkedList;
......@@ -242,9 +242,12 @@ public class BenchmarkJobManager {
List<ResultFileTask> identifiedTasks = new LinkedList<ResultFileTask>();
final String newLineSeparator = "\n";
final String delimiter = ";";
final String summaryFileHeader = "Task;MemoryUsage;WallTime;JobCount";
try {
String line = null;
final String separator = ";";
ResultFileTask processedTask = null;
List<ResultFileJob> jobs = new LinkedList<>();
......@@ -257,7 +260,7 @@ public class BenchmarkJobManager {
continue;
}
String[] columns = line.split(separator);
String[] columns = line.split(delimiter);
if (columns[0].equals(Constants.STATISTICS_TASK_NAME)) {
......@@ -296,12 +299,29 @@ public class BenchmarkJobManager {
} catch (IOException e) {
log.error(e.getMessage(), e);
}
}
for (ResultFileTask task : identifiedTasks) {
Object[] args = {Constants.STATISTICS_TASK_NAME_MAP.get(task.name), task.getJobCount(), task.getAverageMemoryUsage()};
MessageFormat fmt = new MessageFormat(Constants.STATISTICS_OUTPUT_MESSAGE);
System.out.println(fmt.format(args));
FileWriter fileWriter = null;
try {
fileWriter = new FileWriter(filename.getParent().toString() + "/" + Constants.STATISTICS_SUMMARY_FILENAME);
fileWriter.append(summaryFileHeader).append(newLineSeparator);
for (ResultFileTask task : identifiedTasks) {
fileWriter.append(Constants.STATISTICS_TASK_NAME_MAP.get(task.name)).append(delimiter);
fileWriter.append(Double.toString(task.getAverageMemoryUsage())).append(delimiter);
fileWriter.append(Double.toString(task.getAverageWallTime())).append(delimiter);
fileWriter.append(Integer.toString(task.getJobCount()));
fileWriter.append(newLineSeparator);
}
} catch (Exception e) {
log.error(e.getMessage(), e);
} finally {
try {
fileWriter.flush();
fileWriter.close();
} catch (Exception e) {
log.error(e.getMessage(), e);
}
}
}
......
......@@ -37,5 +37,5 @@ public interface Constants {
put("hdf5_xml_output", "Define hdf5 output");
put("resave_hdf5_output", "Resave output to hdf5");
}};
String STATISTICS_OUTPUT_MESSAGE = "{0} needed {1} {1,choice,0#jobs|1#job|1<jobs} and {2} MB of memory in average.";
String STATISTICS_SUMMARY_FILENAME = "summary.csv";
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment