protected void invokeRpcs() throws Exception { Average avg=new Average(); long min=Long.MAX_VALUE, max=0; RequestOptions opts=new RequestOptions(ResponseMode.GET_FIRST, 0).transientFlags(Message.TransientFlag.DONT_LOOPBACK); if(!all_received) System.err.printf("didn't receive all responses: %s\n", rsps); avg.add(time_ns); min=Math.min(min, time_ns); max=Math.max(max, time_ns); System.out.printf("\nround-trip = min/avg/max: %.2f / %.2f / %.2f us\n\n", min/1000.0, avg.getAverage() / 1000.0, max/1000.0);
/** Merges this average with another one */ public <T extends Average> T merge(T other) { if(Util.productGreaterThan(count, (long)Math.ceil(avg), Long.MAX_VALUE) || Util.productGreaterThan(other.count(), (long)Math.ceil(other.average()), Long.MAX_VALUE)) { // the above computation is not correct as the sum of the 2 products can still lead to overflow // a non-weighted avg avg=avg + other.average() / 2.0; } else { // compute the new average weighted by count long total_count=count + other.count(); avg=(count * avg + other.count() * other.average()) / total_count; count=total_count/2; } return (T)this; }
public void reset() {num_blockings=0; avg_blockings.clear();}
public <T extends Average> T merge(T other) { if(other.count() == 0) return (T)this; super.merge(other); if(other instanceof AverageMinMax) { AverageMinMax o=(AverageMinMax)other; this.min=Math.min(min, o.min()); this.max=Math.max(max, o.max()); if(this.values != null) this.values.addAll(o.values); } return (T)this; }
public <T extends Average> T add(long num) { super.add(num); min=Math.min(min, num); max=Math.max(max, num); if(values != null) values.add(num); return (T)this; }
public double getAverageBlockTime() {return avg_blockings.getAverage();} // in ns public void reset() {num_blockings=0; avg_blockings.clear();}
public void writeTo(DataOutput out) throws Exception { super.writeTo(out); Bits.writeLong(min, out); Bits.writeLong(max, out); }
public void readFrom(DataInput in) throws Exception { super.readFrom(in); min=Bits.readLong(in); max=Bits.readLong(in); }
public void init() throws Exception { super.init(); avg=new Average(); }
public boolean decrementIfEnoughCredits(final Message msg, int credits, long timeout) { lock.lock(); try { if(decrement(credits)) return true; if(timeout <= 0) return false; long start=System.nanoTime(); try { credits_available.await(timeout, TimeUnit.MILLISECONDS); } catch(InterruptedException e) { } num_blockings++; avg_blockings.add(System.nanoTime() - start); return decrement(credits); } finally { lock.unlock(); } }
public <T extends Average> T merge(T other) { if(other.count() == 0) return (T)this; super.merge(other); if(other instanceof AverageMinMax) { AverageMinMax o=(AverageMinMax)other; this.min=Math.min(min, o.min()); this.max=Math.max(max, o.max()); if(this.values != null) this.values.addAll(o.values); } return (T)this; }
public String toString() { return String.valueOf(getAverage()); }
public void writeTo(DataOutput out) throws Exception { super.writeTo(out); Bits.writeLong(min, out); Bits.writeLong(max, out); }
public void readFrom(DataInput in) throws Exception { super.readFrom(in); min=Bits.readLong(in); max=Bits.readLong(in); }
public void init() throws Exception { super.init(); avg=new Average(); }
protected void invokeRpcs() throws Exception { Average avg=new Average(); long min=Long.MAX_VALUE, max=0; RequestOptions opts=new RequestOptions(ResponseMode.GET_FIRST, 0).transientFlags(Message.TransientFlag.DONT_LOOPBACK); if(!all_received) System.err.printf("didn't receive all responses: %s\n", rsps); avg.add(time_ns); min=Math.min(min, time_ns); max=Math.max(max, time_ns); System.out.printf("\nround-trip = min/avg/max: %.2f / %.2f / %.2f us\n\n", min/1000.0, avg.getAverage() / 1000.0, max/1000.0);
public void clear() { super.clear(); if(values != null) values.clear(); min=Long.MAX_VALUE; max=0; }
avg_block_time.add(System.nanoTime() - start); return decrement(credits);
@ManagedAttribute(description="Average latency in ms") public double latencyInMs() {return avg.getAverage() / 1000000.0;}
/** Merges this average with another one */ public <T extends Average> T merge(T other) { if(Util.productGreaterThan(count, (long)Math.ceil(avg), Long.MAX_VALUE) || Util.productGreaterThan(other.count(), (long)Math.ceil(other.average()), Long.MAX_VALUE)) { // the above computation is not correct as the sum of the 2 products can still lead to overflow // a non-weighted avg avg=avg + other.average() / 2.0; } else { // compute the new average weighted by count long total_count=count + other.count(); avg=(count * avg + other.count() * other.average()) / total_count; count=total_count/2; } return (T)this; }