Package eu.planets_project.pp.plato.model.measurement

Examples of eu.planets_project.pp.plato.model.measurement.Measurement


                        settings);
        // provide a nice name for the resulting object
        setResultName(result, sampleObject);
        long duration = (System.nanoTime()-start)/(1000000);
        service.addExperience(result.getFeedbackKey(), action.getUrl(),
                new Measurement("roundtripTimeMS",new Double(duration)));
        return result;
    }
View Full Code Here


    public static DetailedExperimentInfo getAverage(ToolExperience toolExp){
        DetailedExperimentInfo averages = new DetailedExperimentInfo();
        for(String key:toolExp.getMeasurements().keySet()) {
            /* average can only calculated of numeric values */
            if (toolExp.getMeasurements().get(key). getList().get(0).getValue() instanceof INumericValue) {
               Measurement m = toolExp.getAverage(key);
               if (!Double.isInfinite(((INumericValue)m.getValue()).value()))
                  averages.getMeasurements().put(key, m);
            }
        }
        return averages;
    }
View Full Code Here

                + key.length());
        ToolConfig config = ToolRegistry.getInstance().getToolConfig(toolIdentifier);
        migrate(data, config, params, result);
       
        normaliseMeasurements(result, toolIdentifier);
        result.getMeasurements().put("input:filesize",new Measurement("input:filesize",data.length));
        return result;
    }
View Full Code Here

            double length = migratedFile.length;
            double elapsed = r.getElapsedTimeMS();
            double elapsedPerMB = ((double)elapsed)/(getMByte(data));

            Measurement me = new Measurement(MigrationResult.MIGRES_ELAPSED_TIME,elapsed);
            result.getMeasurements().put(MigrationResult.MIGRES_ELAPSED_TIME, me);

            for (MeasurableProperty property: getMeasurableProperties()) {
                if (!property.getName().startsWith("machine:")) {
                    Measurement m = new Measurement();
                    m.setProperty(property);
                    PositiveFloatValue v = (PositiveFloatValue) property.getScale().createValue();
                    if (property.getName().equals(MigrationResult.MIGRES_ELAPSED_TIME)) {
                        v.setValue(elapsed);
                        m.setValue(v);
                        result.getMeasurements().put(property.getName(), m);
                    } else if (property.getName().equals(MigrationResult.MIGRES_ELAPSED_TIME_PER_MB)) {
                        v.setValue(elapsedPerMB);
                        m.setValue(v);
                        result.getMeasurements().put(property.getName(), m);
                    } else if (property.getName().equals(MigrationResult.MIGRES_RELATIVE_FILESIZE)) {
                        v.setValue(((double)length)/data.length * 100);
                        m.setValue(v);
                        result.getMeasurements().put(property.getName(), m);
                    } else if (property.getName().equals(MigrationResult.MIGRES_RESULT_FILESIZE)) {
                        v.setValue((double)length);
                        m.setValue(v);
                        result.getMeasurements().put(property.getName(), m);
                    }
                }               
            }
           
View Full Code Here

        // add it to the measurements of MigrationResult
        Machine m = ToolRegistry.getInstance().getMachine(machine);

        for (MeasurableProperty property: getMeasurableProperties()) {
            if (property.getName().startsWith("machine:")) {
                Measurement measurement = new Measurement();
                measurement.setProperty(property);
                FreeStringValue v =(FreeStringValue) property.getScale().createValue();
                if (property.getName().equals(Machine.MACHINE_NAME)) {
                    v.setValue(m.getId());
                } else if (property.getName().equals(Machine.MACHINE_OS)) {
                    v.setValue(m.getOperatingSystem());
                } else if (property.getName().equals(Machine.MACHINE_CPUS)) {
                    v.setValue(m.getCpus());
                } else if (property.getName().equals(Machine.MACHINE_CPUCLOCK)) {
                    v.setValue(m.getCpuClock());
                } else if (property.getName().equals(Machine.MACHINE_CPUTYPE)) {
                    v.setValue(m.getCpuType());
                } else if (property.getName().equals(Machine.MACHINE_MEMORY)) {
                    v.setValue(m.getMemory());
                }
                measurement.setValue(v);
                result.getMeasurements().put(property.getName(), measurement);
            }
        }       
       
    }
View Full Code Here

    protected void collectData(ToolConfig config, long time, MigrationResult result) {
        HPROF_Parser p = new HPROF_Parser();
        p.parse(makeOutputFilename(config, time)+".hprof");
       
        for (MeasurableProperty property: getMeasurableProperties()) {
            Measurement m = new Measurement();
            m.setProperty(property);
            PositiveFloatValue v = (PositiveFloatValue) property.getScale().createValue();
           
//            if (property.getName().equals(MigrationResult.MIGRES_MEMORY_GROSS)) {
//                v.setValue(p.getTotal_allocated());
//            }
//            if (property.getName().equals(MigrationResult.MIGRES_MEMORY_NET)) {
//                v.setValue(p.getTotal_virtual());
//            }

            if (property.getName().equals(MigrationResult.MIGRES_MEMORY_GROSS)) {
                v.setValue(p.getTotal_allocated());
            }

            /**
             * this is NOT the total virtual memory used during execution
             * it's the virtual memory still allocated when HProf collects information
             * - if garbage collector was called, this value is lower than the actual v-memory consumption
             */
            if (property.getName().equals("performance:totalVirtualMemory")) {
                v.setValue(p.getTotal_virtual());
            }
            if (property.getName().equals("performance:totalAllocatedMemory")) {
                v.setValue(p.getTotal_allocated());
            }
            m.setValue(v);
            result.getMeasurements().put(property.getName(), m);
        }
    }
View Full Code Here

                       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();
                }
                /* write header */
                out.append("tool");
                for (String key : allProperties) {
                   out.append(CSV_SEPARATOR).append(key);
                }
                out.newLine();
                /* write averaged values for all actions */
                for (String action: accumulatedAvg.keySet()){
                   /* 1. column: action name */
                   out.append(action);
                   /* followed by all properties */
                   DetailedExperimentInfo average = accumulatedAvg.get(action);
                   for(String prop: allProperties){
                      out.append(CSV_SEPARATOR);
                      Measurement m = average.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();
                }
                out.newLine();
View Full Code Here

        // why does this expect an instance of SampleObject ??!!
        SampleObject r = new SampleObject();
        r.getData().setData(data);
        r.setFullname(filename);
       
        Measurement success = new Measurement();
        success.setProperty(new MeasurableProperty(new BooleanScale(), MigrationResult.MIGRES_SUCCESS));
        success.setValue(success.getProperty().getScale().createValue());
       
        Measurement report = new Measurement();
        report.setProperty(new MeasurableProperty(new FreeStringScale(), MigrationResult.MIGRES_REPORT));
        report.setValue(report.getProperty().getScale().createValue());
       
        try {
            MigrationResult result = service.migrate(e.getAction(), r);
            if (result.isSuccessful()) {
                /* put all info to toolExperience */
                eInfo.getMeasurements().putAll(result.getMeasurements());

                ((BooleanValue)success.getValue()).setValue("true");
                ((FreeStringValue)report.getValue()).setValue(result.getReport());
            } else {
                ((BooleanValue)success.getValue()).setValue("false");
                ((FreeStringValue)report.getValue()).setValue(result.getReport());
            }
            // and return result, (including the migrated object)
            return result;
           
        } catch (Exception e1) {
            ((BooleanValue)success.getValue()).setValue("false");
            ((FreeStringValue)report.getValue()).setValue(e1.getMessage());
            log.error("Migration with service "+ e.getAction().getShortname()+" failed.");
        }
        return null;
    }
View Full Code Here

        Map<SampleObject, DetailedExperimentInfo> detailedInfo = alternative.getExperiment().getDetailedInfo();
        DetailedExperimentInfo detailedExperimentInfo = detailedInfo.get(sample);
        if (detailedExperimentInfo != null) {
            // retrieve the key of minimee's measuredProperty
            String measuredProperty = propertyToMeasuredValues.get(propertyURI);
            Measurement m = detailedExperimentInfo.getMeasurements().get(measuredProperty);
            if (m != null) {
                return m.getValue();
            } else {
                return null;
            }
        } else {
            return null;
View Full Code Here

                                                v.setComment(mResult.getResult());
                                            }
                                        }                                       
                                    }
                                    if (v != null) {
                                        Measurement m = new Measurement();
                                        m.setProperty(p);
                                        // TODO: validate type of value with respect to property(scale)
                                        m.setValue(v);
                                        result.addMeasurement(m);
                                    }
                                }
                            }
                        }
View Full Code Here

TOP

Related Classes of eu.planets_project.pp.plato.model.measurement.Measurement

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.