1 2 12 package com.versant.core.metric; 13 14 19 public class PercentageSumMetric extends DerivedMetric { 20 21 private final Metric a; 22 private final Metric b; 23 24 public PercentageSumMetric(String name, String displayName, String category, 25 String descr, Metric[] args) { 26 this(name, displayName, category, descr, args[0], args[1]); 27 } 28 29 public PercentageSumMetric(String name, String displayName, String category, 30 String descr, Metric a, Metric b) { 31 super(name, displayName, category, descr, 1); 32 this.a = a; 33 this.b = b; 34 } 35 36 40 public int getArgCount() { 41 return 2; 42 } 43 44 52 public double get(MetricDataSource dataSet, int firstSampleNo, int lastSampleNo, 53 int calc, double seconds) { 54 double a = this.a.get(dataSet, firstSampleNo, lastSampleNo, calc, seconds); 55 double b = this.b.get(dataSet, firstSampleNo, lastSampleNo, calc, seconds); 56 double tot = a + b; 57 if (tot == 0.0) return 0.0; 58 return a * 100.0 / tot; 59 } 60 61 64 public int getDefaultCalc() { 65 return CALC_AVERAGE; 66 } 67 68 } 69 70 | Popular Tags |