Package eu.planets_project.pp.plato.model

Examples of eu.planets_project.pp.plato.model.ToolExperience


public class MeasurementStatistics implements Serializable {
    private static final long serialVersionUID = 1588887112971264736L;

    public static ToolExperience generateToolExperience(Map<String,DetailedExperimentInfo> detailedInfos){
        ToolExperience toolExp = new ToolExperience();
        for (DetailedExperimentInfo info : detailedInfos.values()) {
            /* put measurements of sample files to toolExp */
            for (Measurement m : info.getMeasurements().values()) {
               /* for calculating the average only numeric measurements are of interest
                  but we need the list of all available properties to write statistics to files */
               toolExp.addMeasurement(m);
            }
        }
        return toolExp;
    }
View Full Code Here


            Locale locale = Locale.getDefault (  ) ;
            NumberFormat format = NumberFormat.getNumberInstance( locale ) ;
            //new DecimalFormat("##########.##");
                                 
           
            ToolExperience toolExp = null;
            List<String> allProperties = new ArrayList<String>();
            Map<String, DetailedExperimentInfo> accumulatedAvg = new HashMap<String,DetailedExperimentInfo>();
            for (MassMigrationExperiment e : setup.getExperiments()) {
               
                /* calculate average per experiment */
                /* put measurements of sample files to toolExp */
                toolExp = MeasurementStatistics.generateToolExperience(e.getResult());
                /* get calculated average per property */
                DetailedExperimentInfo average = MeasurementStatistics.getAverage(toolExp);
                accumulatedAvg.put(e.getAction().getShortname(), average);
                e.getAverages().clear();
                e.getAverages().put(average);

                /* a list of all properties to iterate over the values */
                allProperties.clear();
                allProperties.addAll(toolExp.getMeasurements().keySet());
                Collections.sort(allProperties);
                /*
                 * write all measurements of this experiment to a file
                 */
                String statistics = FileUtils.makeFilename(makeUniqueActionName(e.getAction()));
                File statisticsFile = new File(currentResultdir, statistics+".csv");
                try {
                    BufferedWriter out = new BufferedWriter(new FileWriter(statisticsFile));
                    StringBuffer header = new StringBuffer();
                    header.append("sample");
                    for (String key : allProperties) {
                       header.append(CSV_SEPARATOR).append(key);
                    }
                    /* write header */
                    out.append(header);                   
                    out.newLine();
                    List<String> keySet = new ArrayList<String>(e.getResult().keySet());
                    String[] toSort = keySet.toArray(new String[]{});
                    java.util.Arrays.sort(toSort,String.CASE_INSENSITIVE_ORDER);
                   
                    /* write measured values for all samples */
                    for (int i = 0; i<toSort.length; i++){
                       String sample = toSort[i];
                       /* 1. column: sample name */
                       out.append(sample);
                       /* followed by all properties */
                       DetailedExperimentInfo info = e.getResult().get(sample);
                       for(String prop: allProperties){
                          out.append(CSV_SEPARATOR);
                          Measurement m = info.getMeasurements().get(prop);
                          if (m != null) {
                             if (m.getValue() instanceof INumericValue) {
                                /* */
                                double value = ((INumericValue)m.getValue()).value();
                                out.append(format.format(value));
                             } else
                                out.append(m.getValue().toString());
                          }
                       }
                       out.newLine();
                    }
                    /* write header again */
                    out.append(header);                   
                    out.newLine();
                    /* and write calculated average */
                    out.append("average");
                    for (String key : allProperties) {
                       out.append(CSV_SEPARATOR);
                       Measurement m = e.getAverages().getMeasurements().get(key);
                       if (m != null) {
                            if (m.getValue() instanceof INumericValue) {
                                double value = ((INumericValue)m.getValue()).value();
                                out.append(format.format(value));
                            } else
                                out.append(m.getValue().toString());
                       }
                    }
                    out.newLine();
                    out.append("startupTime");
                    out.append(CSV_SEPARATOR);

                    try {
                        out.append(Double.toString(toolExp.getStartupTime()));
                    } catch (Exception ex) {
                        log.error("Error in calculating the startup time (linear regression): " + ex.getMessage());
                        out.append("Err");
                    }
                   
                    out.newLine();
                    out.close();
                } catch (IOException e1) {
                    log.error("Could not write statistics for: " + statistics, e1);
                }
            }
            /*
             * and write accumulated values
             */
            File statisticsFile = new File(currentResultdir, "accumulated.csv");
            allProperties.clear();
            allProperties.add(MigrationResult.MIGRES_ELAPSED_TIME_PER_MB);
            allProperties.add(MigrationResult.MIGRES_USED_TIME_PER_MB);
            allProperties.add(MigrationResult.MIGRES_ELAPSED_TIME);
            allProperties.add(MigrationResult.MIGRES_USED_TIME);
            //...
           
            try {
                BufferedWriter out = new BufferedWriter(new FileWriter(statisticsFile));
                /* write machine info */
                if (toolExp != null) {
                    // use machine info of last experiment!
                    for (String prop: toolExp.getMeasurements().keySet()) {
                        if (prop.startsWith("machine:")){
                            out.append(prop)
                            .append(CSV_SEPARATOR)
                            .append(toolExp.getMeasurements().get(prop).getList().get(0).getValue().getFormattedValue());
                            out.newLine();
                        }
                    }
                    out.newLine();
                }
View Full Code Here

     * @return the {@link ToolExperience} corresponding to the identifier.
     * If there was no ToolExperience defined yet for this ID, a new one will
     * be created and put into the map!
     */
    public ToolExperience getToolExperience(String tool) {
        ToolExperience b = toolExperience.get(tool);
        if (b == null) {
            b = new ToolExperience();
            toolExperience.put(tool, b);
        }
        return b;
    }   
View Full Code Here

     * identified by the provided id
     * @param tool identifies the {@link ToolExperience} to which to add the measurement
     * @param m
     */
    public void addExperience(String tool,Measurement m) {
        ToolExperience b = getToolExperience(tool);
        b.addMeasurement(m);
    }   
View Full Code Here

                    log.warn("Init dir " + directory + " is not a directory.");
                }
            }
        }
        for (ToolConfig c: ToolRegistry.getInstance().getAllToolConfigs().values()) {
            ToolExperience ex = ToolRegistry.getInstance().getEb().getToolExperience(c.getName());
            log.debug("Startup time of " +c.getName()+": "+ex.getStartupTime());
        }
       
        return null;
    }
View Full Code Here

    public double calculateBenchmarkScore() {
        if (benchmarkConfigs.size() == 0)
            return 1.0;
        double score = 0.0;
        for (String config : benchmarkConfigs.keySet()) {
            ToolExperience ex = eb.getToolExperience(config);
           
                Measurement m = ex.getAverage(MigrationResult.MIGRES_ELAPSED_TIME_PER_MB);
                if (m != null) {
                        INumericValue v =  (INumericValue) m.getValue();
                        score += v.value();
                }
        }
View Full Code Here

TOP

Related Classes of eu.planets_project.pp.plato.model.ToolExperience

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.