public Statistics divideBy(Double val) { Statistics st = new Statistics(); for (String k : keySet()) st.put(k, get(k) / val); return st; }
protected Statistics update(Statistics st, Double value) { Double min = st.get("minimum"); if (min == null) min = value; else min = Math.min(min, value); st.put("minimum", min); Double max = st.get("maximum"); if (max == null) max = value; else max = Math.max(max, value); st.put("maximum", max); st.add("sum", value); st.add("count", 1.0d); st.put("average", st.get("sum") / st.get("count")); return st; }
/** * @see stream.service.Service#reset() */ @Override public void reset() throws Exception { synchronized (currentStatistics) { currentStatistics.clear(); } }
public void add(String key, Double val) { if (this.containsKey(key)) { Double d = get(key) + val; put(key, d); } else put(key, val); } }
@Override public Statistics getStatistics() { Statistics st = new Statistics(); st.put("dataRate", rate); return st; }
/** * @see stream.statistics.StatisticsService#getStatistics() */ @Override public Statistics getStatistics() { Statistics stats = new Statistics(); Double time = nanoTime.doubleValue(); Double items = itemsProcessed.doubleValue(); /* * Double rate = 0.0; if (time > 0.0d) { rate = items / time / 1000L; } */ stats.setName("Average Throughput"); stats.put("@avg:milliseconds-per-item", time / items); return stats; } }
/** * @see stream.statistics.StatisticsService#getStatistics(java.lang.String) */ @Override public Statistics getStatistics() { return new Statistics(statistics); }
/** * @see stream.statistics.Sum#updateStatistics(stream.Data) */ @Override public void updateStatistics(Data item) { if (keys == null) return; count += 1.0d; for (String key : keys) { Double val = null; try { val = new Double(item.get(key) + ""); } catch (Exception e) { val = null; } if (val != null) { statistics.add(key, val); if (prefix != null) item.put(prefix + key, statistics.get(key) / count); else item.put(key, statistics.get(key) / count); } } }
/** * @see stream.statistics.History#add(java.lang.Long, java.lang.Object) */ @Override public void add(Long timestamp, Statistics data) { Long x = adjust(timestamp); Statistics st = get(x); if (st == null) { st = new Statistics(data); this.map.put(x, st); } else { st.add(data); } this.last = x; } }
/** * @see stream.Processor#process(stream.Data) */ @Override public Data process(Data input) { if (service != null) { Statistics stats = service.getStatistics(); for (String key : stats.keySet()) { input.put(key, stats.get(key)); } } else { log.error("No statistics service connected!"); } if (services != null) { for (int i = 0; i < services.length; i++) { if (services[i] != null) { Statistics stats = services[i].getStatistics(); for (String key : stats.keySet()) { input.put(key, stats.get(key)); } } } } return input; } }
protected Statistics update(Statistics st, String value) { st.add(value, 1.0d); return st; }
public void tikzHistogram(Statistics st, Keys ks, OutputStream out) { List<String> keyList = new ArrayList<String>(ks.select(st.keySet())); tikzHistogram(st, keyList, out); }
@Override public Statistics getStatistics() { Statistics st = new Statistics(); synchronized (rate) { st.put("dataRate", new Double(rate.doubleValue())); } return st; }