List of usage examples for com.google.common.util.concurrent AtomicLongMap get
public long get(K key)
From source file:co.mitro.core.util.RpcLogReader.java
public static void main(String[] args) throws IOException { AtomicLongMap<String> counter = AtomicLongMap.<String>create(); Map<String, Span> txnLength = new HashMap<>(); Span duration = new Span(); for (int i = 0; i < args.length; ++i) { String filename = args[i]; System.err.println("Reading file: " + filename); JsonRecordReader rr = JsonRecordReader.MakeFromFilename(filename); JsonRecordReader.JsonLog log;/*from w w w . j a va 2s .co m*/ try { while (null != (log = rr.readJson())) { counter.incrementAndGet(log.metadata.endpoint); duration.addTime(log.metadata.timestamp); if (log.metadata.endpoint.endsWith("BeignTransaction") || log.payload.implicitBeginTransaction) { txnLength.put((String) ((Map) log.metadata.response).get("transactionId"), new Span(log.metadata.timestamp)); } else if (!Strings.isNullOrEmpty(log.payload.transactionId)) { txnLength.get(log.payload.transactionId).addTime(log.metadata.timestamp); } } } catch (EOFException e) { System.err.println("unexpected end of file; skipping"); } } System.out.println("total duration: " + duration.duration()); for (String k : counter.asMap().keySet()) { System.out.println(k + ": " + counter.get(k)); } List<Long> times = new ArrayList<>(); for (Span s : txnLength.values()) { times.add(s.duration()); } Collections.sort(times); double meanTime = 0; for (Long l : times) { meanTime += l; } meanTime /= txnLength.size(); double stdDev = 0; for (Long l : times) { stdDev += Math.pow((l - meanTime), 2); } stdDev /= txnLength.size(); stdDev = Math.pow(stdDev, 0.5); // percentiles long PERCENTILES = 10; for (int i = 0; i <= PERCENTILES; i += 1) { System.out.println("percentile " + i * PERCENTILES + ": " + times.get((int) ((times.size() - 1) * i / PERCENTILES))); } System.out.println("write txns:"); System.out.println("num: " + txnLength.size() + ", mean:" + meanTime + ", stddev:" + stdDev); }