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

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


     * uses its property name as key for this hashmap
     *  
     * @param m
     */
    public void addMeasurement(Measurement m) {
        Measurements ms = measurements.get(m.getProperty().getName());
        if (ms == null) {
            ms = new Measurements();
            measurements.put(m.getProperty().getName(), ms);
        }
        ms.addMeasurement(m);
    }
View Full Code Here


     *
     * @param propertyName
     * @return
     */
    public Measurement getAverage(String propertyName) {
        Measurements m = measurements.get(propertyName);
        return (m == null ? null : m.getAverage());
    }
View Full Code Here

     *
     * @param propertyName
     * @return
     */
    public int getSize(String propertyName) {
        Measurements m = measurements.get(propertyName);
        return (m == null ? 0 : m.getSize());
    }
View Full Code Here

     * time and size of the file that has been migrated.
     *
     * @return startup time of the tool
     */
    public double getStartupTime() {
        Measurements elapsedTimeMeasurements = measurements.get(MigrationResult.MIGRES_USED_TIME);
        Measurements resultFileSizes = measurements.get(MigrationResult.MIGRES_RESULT_FILESIZE);
        Measurements relativeFileSizes = measurements.get(MigrationResult.MIGRES_RELATIVE_FILESIZE);
       
        if (elapsedTimeMeasurements == null || resultFileSizes == null || relativeFileSizes == null) {
            return 0.0;
        }
               
        if (!((elapsedTimeMeasurements.getSize() == resultFileSizes.getSize())
                && (resultFileSizes.getSize() == relativeFileSizes.getSize()))) {
            return 0.0;
        }

        // For some reason the library cannot calculate the function if it has only 2 values.
        // IllegalArgumentException: The degrees of freedom must be greater than 0
        //  is the result.
        if (elapsedTimeMeasurements.getSize() <= 2) {
            return 0.0;
        }
       
        if (elapsedTimeMeasurements.getSize() <= 0) {
            return 0.0;
        }
       
        double[] xArray = new double[elapsedTimeMeasurements.getSize()];
        double[] yArray = new double[elapsedTimeMeasurements.getSize()];
       
        int i = 0;
       
        for (i = 0; i < resultFileSizes.getSize(); i++) {
           
            double resultFileSize = ((INumericValue)resultFileSizes.getList().get(i).getValue()).value();
            double factor = ((INumericValue)relativeFileSizes.getList().get(i).getValue()).value();
           
            xArray[i] = (resultFileSize / factor) * 100.0;
            yArray[i] = ((INumericValue)elapsedTimeMeasurements.getList().get(i).getValue()).value();
        }
       
View Full Code Here

                    pcrFile = makePCR(time);
                    cprFile = compare(inXCDL,outXCDL,pcrFile,wDir);  
   
                    if (!"".equals(cprFile)) {
                        // digest output (cf. plato integration)
                        Measurements measurements =
                            extractMeasurements(cprFile, getMeasurableProperties());
                        // write stats (only stats for the moment) to MigrationResult
                        for (Measurement m : measurements.getList()) {
                            list.add(m);
                        }
                    }
                }
            } catch (Exception e) {
View Full Code Here

            new File(cprFile).delete();
        }
    }

    private Measurements extractMeasurements(String cprFile, List<MeasurableProperty> properties) {
        Measurements result = new Measurements();
        try {
            ComparatorUtils compUtils = new ComparatorUtils();
            List<CompareResult> compResult = compUtils.parseResponse(cprFile);
            if (compResult.size() == 1) {
                /* we compare two xcdl files, which correspond to one compSet */
                for(MeasurableProperty p : properties) {
                    /*
                     * get all values for measureable properties that correspond to xcl properties:
                     * they have the pattern: xcl:<propertyName>:<metricName>
                     */
                    String[] keyParts =  p.getName().split(":");
                    if (keyParts.length == 3) {
                        if ("xcl".equals(keyParts[0])) {
                            CprProperty cprP =
                               compResult.get(0).getProperties().get(keyParts[1]);
                            if (cprP != null) {
                                String id = MetricToScaleMapping.getMetricId(keyParts[2]);
                                if (id != null) {
                                    Value v = null;                                   
                                    Scale s = MetricToScaleMapping.getScale(id);
                                    if (s == null) {
                                        // There is a new XCLMetric we have not registered in MetricToScaleMapping yet...
                                        log.debug("CPR: unkown metricId: " +  id);
                                    } else {
                                        // scale found, so we can create a value object
                                        v =  s.createValue();
                                        v.setScale(null);
                                       
                                        CprMetricResult mResult = cprP.getResultMetrics().get(id);
                                        if (mResult != null) {
                                            if ("ok".equals(mResult.getState())) {
                                                v.parse(mResult.getResult());
                                                v.setComment("xcdl values(sample::result)=(" + cprP.getSource()+"::" + cprP.getTarget()+")");
                                            } else {
                                                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.Measurements

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.