diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/.classpath b/edu.kit.ipd.descartes.adaptation.evaluation.performance/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..ad32c83a7885b8953a938b41df3b4fd4fe1aae01 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="bin"/> +</classpath> diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/.project b/edu.kit.ipd.descartes.adaptation.evaluation.performance/.project new file mode 100644 index 0000000000000000000000000000000000000000..b2d7d93215e4b9a6380219115ee1697460fc5a88 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>edu.kit.ipd.descartes.adaptation.evaluation.performance</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/.settings/org.eclipse.jdt.core.prefs b/edu.kit.ipd.descartes.adaptation.evaluation.performance/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..c537b63063ce6052bdc49c5fd0745b078f162c90 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,7 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/.settings/org.eclipse.pde.core.prefs b/edu.kit.ipd.descartes.adaptation.evaluation.performance/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000000000000000000000000000000000000..e8ff8be0bab6eab17a4ac1284455580f8e186ea2 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +eclipse.preferences.version=1 +pluginProject.equinox=false +pluginProject.extensions=false +resolve.requirebundle=false diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/META-INF/MANIFEST.MF b/edu.kit.ipd.descartes.adaptation.evaluation.performance/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..1bd23780702df4658859d5a36262fab51875b691 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/META-INF/MANIFEST.MF @@ -0,0 +1,19 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: PerformanceEvaluator +Bundle-SymbolicName: edu.kit.ipd.descartes.adaptation.evaluation.performance +Bundle-Version: 1.0.0.qualifier +Bundle-Activator: edu.kit.ipd.descartes.adaptation.evaluation.performance.Activator +Bundle-Vendor: Descartes Research Group +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Import-Package: edu.kit.ipd.descartes.core, + edu.kit.ipd.descartes.mm.adaptation, + edu.kit.ipd.descartes.perfdatarepo, + org.apache.log4j;version="1.2.15", + org.eclipse.emf.common.util, + org.eclipse.emf.ecore, + org.eclipse.emf.ecore.util, + org.osgi.framework;version="1.3.0" +Export-Package: edu.kit.ipd.descartes.adaptation.evaluation.performance, + edu.kit.ipd.descartes.adaptation.evaluation.performance.weightingfunction + diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/build.properties b/edu.kit.ipd.descartes.adaptation.evaluation.performance/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..34d2e4d2dad529ceaeb953bfcdb63c51d69ffed2 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/Activator.java b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/Activator.java new file mode 100644 index 0000000000000000000000000000000000000000..4ef0e8153fb3b3ea4cf4a8aa1bd822e1c92553fa --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/Activator.java @@ -0,0 +1,30 @@ +package edu.kit.ipd.descartes.adaptation.evaluation.performance; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator implements BundleActivator { + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + } + + /* + * (non-Javadoc) + * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } + +} diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/IEvaluator.java b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/IEvaluator.java new file mode 100644 index 0000000000000000000000000000000000000000..0256a89bd965031255a232308a60ecdcbd01701b --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/IEvaluator.java @@ -0,0 +1,38 @@ +package edu.kit.ipd.descartes.adaptation.evaluation.performance; + +import edu.kit.ipd.descartes.mm.adaptation.Objective; +import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic; + +/** + * Evaluates a tactic. + * + * @author nhuber + * + */ +public interface IEvaluator { + + /** + * Evaluates the impact of a {@link WeightedTactic}. + * + * @param tactic + * The weighted tactic to evaluate + */ + public void evaluate(WeightedTactic tactic); + + /** + * Checks if any QoS property has degraded significantly, i.e. any {@link Objective}has been + * violated, after applying the tactic. + * + * @param tactic + * @return + */ + public boolean slaViolated(WeightedTactic tactic); + + /** + * Reduces the weight of the given tactic. + * + * @param tactic + */ + public void punishTactic(WeightedTactic tactic); + +} diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/WeightingFunctionEvaluator.java b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/WeightingFunctionEvaluator.java new file mode 100644 index 0000000000000000000000000000000000000000..acc3ec736e4281d8864636700391078585e2999f --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/WeightingFunctionEvaluator.java @@ -0,0 +1,86 @@ +package edu.kit.ipd.descartes.adaptation.evaluation.performance; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; + +import edu.kit.ipd.descartes.adaptation.evaluation.performance.weightingfunction.IWeightingFunction; +import edu.kit.ipd.descartes.adaptation.evaluation.performance.weightingfunction.WeightedSumWeightingFunctionHelper; +import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic; +import edu.kit.ipd.descartes.mm.adaptation.WeightingFunction; +import edu.kit.ipd.descartes.perfdatarepo.Impact; +import edu.kit.ipd.descartes.perfdatarepo.MetricValue; +import edu.kit.ipd.descartes.perfdatarepo.Result; + +/** + * Evaluates a given {@link WeightedTactic} using the weighted tactic's {@link WeightingFunction}. + * + * @author nhuber + * + */ +public class WeightingFunctionEvaluator implements IEvaluator { + + private static final String RESPONSETIME_IDENTIFIER = "ResponseTime"; + private IWeightingFunction calculator = null; + private static Logger logger = Logger.getLogger(WeightingFunctionEvaluator.class); + + /* + * (non-Javadoc) + * + * @see edu.kit.ipd.descartes.adaptation.evaluation.IEvaluator#evaluate() + */ + @Override + public void evaluate(WeightedTactic tactic) { + WeightingFunction f = tactic.getParentStrategy().getWeightingFunction(); + + final String functionClassName = f.getWeightingFunctionImplementation(); + + Object o = null; + try { + o = Class.forName(functionClassName).newInstance(); + } catch (final ClassNotFoundException e) { + e.printStackTrace(); + } catch (final InstantiationException e) { + e.printStackTrace(); + } catch (final IllegalAccessException e) { + e.printStackTrace(); + } + + if (!IWeightingFunction.class.isInstance(o)) { + throw new RuntimeException("Expected a class implementing " + IWeightingFunction.class.getName()); + } + + calculator = (IWeightingFunction) o; + calculator.setWeightingFunction(f); + double newWeight = calculator.calculateWeight(tactic); + logger.debug("Setting new weight of " + tactic.getName() + " to " + newWeight); + tactic.setCurrentWeight(newWeight); + } + + public boolean slaViolated(WeightedTactic tactic) { + Impact impact = tactic.getLastImpact(); + Result before = impact.getBefore(); + Result after = impact.getAfter(); + EList<MetricValue> afterMetricValues = after.getMetricValues(); + + for (MetricValue afterMetricValue : afterMetricValues) { + // calculated delta=(after-before) + double afterValue = afterMetricValue.getValue(); + double beforeValue = WeightedSumWeightingFunctionHelper.getValueForMetricType( + afterMetricValue.getMetricType(), before); + + if (afterMetricValue.getMetricType().getName().contains(RESPONSETIME_IDENTIFIER) + && afterValue > beforeValue) { + return true; + } + } + + return false; + } + + @Override + public void punishTactic(WeightedTactic tactic) { + double weight = 0.0; + logger.info("Punishing tactic, setting weight to " + weight); + tactic.setCurrentWeight(weight); + } +} diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/BlueYonderResourceEfficiencyWeightingFunction.java b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/BlueYonderResourceEfficiencyWeightingFunction.java new file mode 100644 index 0000000000000000000000000000000000000000..ffa322329ed461f3ed25eacf69a9ad242b8ecb86 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/BlueYonderResourceEfficiencyWeightingFunction.java @@ -0,0 +1,78 @@ +package edu.kit.ipd.descartes.adaptation.evaluation.performance.weightingfunction; + +import org.apache.log4j.Logger; + +import edu.kit.ipd.descartes.mm.adaptation.WeightedMetric; +import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic; +import edu.kit.ipd.descartes.mm.adaptation.WeightingFunction; +import edu.kit.ipd.descartes.perfdatarepo.Impact; +import edu.kit.ipd.descartes.perfdatarepo.MetricValue; +import edu.kit.ipd.descartes.perfdatarepo.Result; + +public class BlueYonderResourceEfficiencyWeightingFunction implements IWeightingFunction { + + private static final String UTIL_IDENTIFIER = "Util"; + private static final double THRESHOLD = 0.05; + private WeightingFunction function = null; + private static Logger logger = Logger.getLogger(BlueYonderResourceEfficiencyWeightingFunction.class); + +// public BlueYonderResourceEfficiencyWeightingFunction() { +// AbstractEcoreModelLoader loader = PerformanceDataRepositoryModelLoader.getInstance(); +// String pdrLocation = loader.getCurrentModelUri().toFileString(); +// logger.debug("Initializing query engine adaptor for performance data repository " + pdrLocation); +// qea = new QueryEngineAdapter(pdrLocation); +// } + + @Override + public void setWeightingFunction(WeightingFunction function) { + this.function = function; + } + + @Override + /* + * (non-Javadoc) + * + * @see + * edu.kit.ipd.descartes.adaptation.evaluation.performance.weightingfunction.IWeightingFunction#calculateWeight + * (edu.kit.ipd.descartes.mm.adaptation.WeightedTactic) + */ + public double calculateWeight(WeightedTactic weightedTactic) { + double newWeight = 0.0; + Impact impact = weightedTactic.getLastImpact(); + Result before = impact.getBefore(); + Result after = impact.getAfter(); + + for (WeightedMetric wm : function.getWeightedMetrics()) { + double afterValue = WeightedSumWeightingFunctionHelper.getValueForMetricType(wm.getMetricType(), after); + double beforeValue = WeightedSumWeightingFunctionHelper.getValueForMetricType(wm.getMetricType(), before); + double delta = afterValue - beforeValue; + newWeight += delta * wm.getWeight(); + } + + int activeResourceDelta = calcActiveResourceDelta(impact); + logger.debug("Delta of active resources: " + activeResourceDelta); + // TODO: Implement something more sophisticated + newWeight = activeResourceDelta; + + return newWeight; + } + + private int calcActiveResourceDelta(Impact impact) { + Result before = impact.getBefore(); + Result after = impact.getAfter(); + int activeResourcesBefore = getActiveResources(before); + int activeResourcesAfter = getActiveResources(after); + return activeResourcesAfter - activeResourcesBefore; + } + + private int getActiveResources(Result result) { + int counter = 0; + for (MetricValue v : result.getMetricValues()) { + // TODO parse with regexp or something more clever + if (v.getMetricType().getName().contains(UTIL_IDENTIFIER) && v.getValue() > THRESHOLD) + counter++; + } + return counter; + } + +} diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/IWeightingFunction.java b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/IWeightingFunction.java new file mode 100644 index 0000000000000000000000000000000000000000..70ebe7f5e4e38d8fc07bdf1d6c25bd6ec11d9cd8 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/IWeightingFunction.java @@ -0,0 +1,33 @@ +package edu.kit.ipd.descartes.adaptation.evaluation.performance.weightingfunction; + +import edu.kit.ipd.descartes.mm.adaptation.Tactic; +import edu.kit.ipd.descartes.mm.adaptation.WeightedMetric; +import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic; +import edu.kit.ipd.descartes.mm.adaptation.WeightingFunction; + +/** + * @author nhuber + * + */ +public interface IWeightingFunction { + + + /** + * Sets the {@link WeightingFunction} that can be used + * by the {@link WeightingFunction} to derive the + * {@link WeightedMetric}s used to calculate the weight. + * + * @param function + */ + void setWeightingFunction(WeightingFunction function); + + /** + * Calculates the new weight of the given {@link Tactic}. + * + * @param impact + * @return + */ + double calculateWeight(WeightedTactic weightedTactic); + + +} diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/RandomWeightsWeightingFunction.java b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/RandomWeightsWeightingFunction.java new file mode 100644 index 0000000000000000000000000000000000000000..6f2ccb37a5fda2d7af2cce272f2c23003193e281 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/RandomWeightsWeightingFunction.java @@ -0,0 +1,20 @@ +package edu.kit.ipd.descartes.adaptation.evaluation.performance.weightingfunction; + +import java.util.Random; + +import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic; +import edu.kit.ipd.descartes.mm.adaptation.WeightingFunction; + +public class RandomWeightsWeightingFunction implements IWeightingFunction { + + @Override + public double calculateWeight(WeightedTactic weightedTactic) { + Random r = new Random(System.currentTimeMillis()); + return r.nextDouble(); + } + + @Override + public void setWeightingFunction(WeightingFunction function) { + // Left empty intentionally + } +} diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/WeightedSum.java b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/WeightedSum.java new file mode 100644 index 0000000000000000000000000000000000000000..becd9b28eea9244739032c258079d900f247c741 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/WeightedSum.java @@ -0,0 +1,62 @@ +package edu.kit.ipd.descartes.adaptation.evaluation.performance.weightingfunction; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; + +import edu.kit.ipd.descartes.mm.adaptation.WeightedTactic; +import edu.kit.ipd.descartes.mm.adaptation.WeightingFunction; +import edu.kit.ipd.descartes.perfdatarepo.Impact; +import edu.kit.ipd.descartes.perfdatarepo.MetricValue; +import edu.kit.ipd.descartes.perfdatarepo.Result; + +public class WeightedSum implements IWeightingFunction { + + private Logger logger = Logger.getLogger(WeightedSum.class); + private WeightingFunction weightingFunction = null; + + public WeightedSum() { + } + + public WeightingFunction getWeightingFunction() { + return weightingFunction; + } + + @Override + public void setWeightingFunction(WeightingFunction weightingFunction) { + this.weightingFunction = weightingFunction; + } + + @Override + public double calculateWeight(WeightedTactic weightedtactic) { + + double newWeight = 0.0; + Impact impact = weightedtactic.getLastImpact(); + Result before = impact.getBefore(); + Result after = impact.getAfter(); + EList<MetricValue> afterMetricValues = after.getMetricValues(); + + for (MetricValue afterMetricValue : afterMetricValues) { + // calculated delta=(after-before) + double afterValue = afterMetricValue.getValue(); + double beforeValue = WeightedSumWeightingFunctionHelper + .getValueForMetricType(afterMetricValue.getMetricType(), before); + double delta = afterValue - beforeValue; + + // get the corresponding weight + double weightOfMetric = WeightedSumWeightingFunctionHelper.getWeightForMetricType(weightingFunction, + afterMetricValue.getMetricType()); + + if (Double.isNaN(weightOfMetric)) + logger.debug("WeightingFunction "+ weightingFunction.getName()+" has no weight specified for metric type " + afterMetricValue.getMetricType().getName() + ". Skipping..."); + else { + // add it + newWeight += weightOfMetric * delta; + logger.debug("Delta for metric type " + afterMetricValue.getMetricType().getName() + " was: " + delta + + " and weight is " + weightOfMetric); + } + } + + return newWeight; + } + +} diff --git a/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/WeightedSumWeightingFunctionHelper.java b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/WeightedSumWeightingFunctionHelper.java new file mode 100644 index 0000000000000000000000000000000000000000..83236bf163e52de4a5ff6fdb5ddc09ec25bcaa46 --- /dev/null +++ b/edu.kit.ipd.descartes.adaptation.evaluation.performance/src/edu/kit/ipd/descartes/adaptation/evaluation/performance/weightingfunction/WeightedSumWeightingFunctionHelper.java @@ -0,0 +1,64 @@ +package edu.kit.ipd.descartes.adaptation.evaluation.performance.weightingfunction; + +import org.apache.log4j.Logger; +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.ecore.util.EcoreUtil; + +import edu.kit.ipd.descartes.mm.adaptation.WeightedMetric; +import edu.kit.ipd.descartes.mm.adaptation.WeightingFunction; +import edu.kit.ipd.descartes.perfdatarepo.MetricType; +import edu.kit.ipd.descartes.perfdatarepo.MetricValue; +import edu.kit.ipd.descartes.perfdatarepo.Result; + +public class WeightedSumWeightingFunctionHelper { + + static Logger logger = Logger.getLogger(WeightedSumWeightingFunctionHelper.class); + + /** + * + * @param function + * @param metricType + * @return Returns the weight of the {@code meticType} of the given {@code function}.<br> + * Returns {@code Double.NaN} if the {@code metricType} was not found. + */ + public static double getWeightForMetricType(WeightingFunction function, MetricType metricType) { + EList<WeightedMetric> weightedMetrics = function.getWeightedMetrics(); + + for (WeightedMetric weightedMetric : weightedMetrics) { + if (EcoreUtil.equals(weightedMetric.getMetricType(), metricType)) + return weightedMetric.getWeight(); + else if (weightedMetric.getMetricType().getName().equals(metricType.getName())) { + logger.debug("Could not find identical metric, using matching name instead"); + return weightedMetric.getWeight(); + } + } + + return Double.NaN; + } + + /** + * Searches the {@link MetricValue} of the given {@link MetricType} in the {@link Result} + * <code>resultBefore</code> + * + * @param metricType + * The type of the metric to find + * @param result + * The result to search + * @return + */ + public static double getValueForMetricType(MetricType metricType, Result result) { + EList<MetricValue> metricValues = result.getMetricValues(); + + for (MetricValue metricValue : metricValues) { + if (sameMetricType(metricValue, metricType)) + return metricValue.getValue(); + } + return Double.NaN; + } + + public static boolean sameMetricType(MetricValue metricValue, MetricType metricType) { +// return metricValue.getMetricType().equals(metricType); + return (metricValue.getMetricType().getName().equals(metricType.getName())); +// && metricValue.getMetricType().getId().equals(metricType.getId())); + } +}