@Override public void reset() { for (PerformanceLogger performanceLogger : performanceLoggers) { performanceLogger.reset(); } }
/** * Creates a new logging decorator for the protocol suite. * * @param protocolSuite the original protocol suite to log for. */ public NumericSuiteLogging(ProtocolSuiteNumeric<ResourcePoolT> protocolSuite) { this.delegateSuite = protocolSuite; this.aggregate = new PerformanceLoggerCountingAggregate(); }
@Override public Map<String, Long> getLoggedValues() { return aggregate.getLoggedValues(); } }
> conf = new HashMap<>(); for (int playerId : netConf.keySet()) { PerformanceLoggerCountingAggregate aggregate = new PerformanceLoggerCountingAggregate(); ProtocolSuiteNumeric<DummyArithmeticResourcePool> ps = new DummyArithmeticProtocolSuite( fieldDefinition, maxBitLength, fixedPointPrecision); if (logPerformance) { ps = new NumericSuiteLogging<>(ps); aggregate.add((PerformanceLogger) ps); evalStrategy.getStrategy(); if (logPerformance) { batchEvaluationStrategy = new BatchEvaluationLoggingDecorator<>(batchEvaluationStrategy); aggregate.add((PerformanceLogger) batchEvaluationStrategy); evaluator = new EvaluatorLoggingDecorator<>(evaluator); aggregate.add((PerformanceLogger) evaluator); Network asyncNetwork = new SocketNetwork(partyNetConf); if (logPerformance) { NetworkLoggingDecorator network = new NetworkLoggingDecorator(asyncNetwork); aggregate.add(network); return network; } else { PerformancePrinter printer = new DefaultPerformancePrinter(); for (PerformanceLogger pl : performanceLoggers.values()) { printer.printPerformanceLog(pl);
for (int playerId : netConf.keySet()) { PerformanceLoggerCountingAggregate aggregate = new PerformanceLoggerCountingAggregate(); if(logPerformance) { BinarySuiteLogging<ResourcePoolImpl> decoratedSuite = new BinarySuiteLogging<>(new DummyBooleanProtocolSuite()); aggregate.add(decoratedSuite); ps = decoratedSuite; strat = new BatchEvaluationLoggingDecorator<>(strat); aggregate.add((PerformanceLogger) strat); evaluator = new EvaluatorLoggingDecorator<>(evaluator); aggregate.add((PerformanceLogger) evaluator); network = new SocketNetwork(partyNetConf); if (logPerformance) { network = new NetworkLoggingDecorator(network); aggregate.add((PerformanceLogger) network); PerformancePrinter printer = new DefaultPerformancePrinter(); for (PerformanceLogger pl : performanceLoggers.get(id)) { printer.printPerformanceLog(pl);
@Test public void getNoOfParties() throws Exception { NetworkLoggingDecorator networkLoggingDecorator = new NetworkLoggingDecorator(new Network() { @Override public void send(int partyId, byte[] data) { } @Override public byte[] receive(int partyId) { return new byte[0]; } @Override public int getNoOfParties() { return 22; } }); assertThat(networkLoggingDecorator.getNoOfParties(), is(22)); // This should be a nil operation since my network does not implement closeable networkLoggingDecorator.close(); } }
@Override public Comparison createComparison(ProtocolBuilderNumeric builder) { ComparisonLoggerDecorator comparisonLoggerDecorator = new ComparisonLoggerDecorator(delegateFactory.createComparison(builder)); aggregate.add(comparisonLoggerDecorator); return comparisonLoggerDecorator; }
@Override public Binary createBinary(ProtocolBuilderBinary builder) { BinaryLoggingDecorator binaryLogger = new BinaryLoggingDecorator(delegateFactory.createBinary(builder)); aggregate.add(binaryLogger); return binaryLogger; }
@Override public Comparison createComparison(ProtocolBuilderBinary builder) { BinaryComparisonLoggingDecorator comparison = new BinaryComparisonLoggingDecorator(delegateFactory.createComparison(builder)); aggregate.add(comparison); return comparison; } };
@Override public Numeric createNumeric(ProtocolBuilderNumeric builder) { NumericLoggingDecorator numericLoggingDecorator = new NumericLoggingDecorator(delegateFactory.createNumeric(builder)); aggregate.add(numericLoggingDecorator); return numericLoggingDecorator; }
@Override public Map<String, Long> getLoggedValues() { Map<String, Long> result = new HashMap<>(); for (PerformanceLogger performanceLogger : performanceLoggers) { Map<String, Long> loggedValues = performanceLogger.getLoggedValues(); for (String key : loggedValues.keySet()) { result.merge(key, loggedValues.get(key), (left, right) -> left + right); } } return result; }
@Override public byte[] receive(int partyId) { byte[] res = this.delegate.receive(partyId); int noBytes = res.length; partyStatsMap.computeIfAbsent(partyId, (i) -> new PartyStats()).recordTransmission(noBytes); return res; }
@Override public void reset() { aggregate.reset(); }
new HashMap<>(); for (int playerId : netConf.keySet()) { PerformanceLoggerCountingAggregate aggregate = new PerformanceLoggerCountingAggregate(); protocolSuite = new NumericSuiteLogging<>(protocolSuite); aggregate.add((PerformanceLogger) protocolSuite); batchEvalStrat = new BatchEvaluationLoggingDecorator<>(batchEvalStrat); aggregate.add((PerformanceLogger) batchEvalStrat); evaluator = new EvaluatorLoggingDecorator<>(evaluator); aggregate.add((PerformanceLogger) evaluator); Network network = new SocketNetwork(netConf.get(playerId)); if (logPerformance) { network = new NetworkLoggingDecorator(network); aggregate.add((NetworkLoggingDecorator) network); return network; } else { PerformancePrinter printer = new DefaultPerformancePrinter(); for (PerformanceLogger pl : performanceLoggers.values()) { printer.printPerformanceLog(pl);
/** * Creates a new logging decorator for the protocol suite. * * @param protocolSuite the original protocol suite to log for. */ public BinarySuiteLogging(ProtocolSuiteBinary<ResourcePoolT> protocolSuite) { this.delegateSuite = protocolSuite; this.aggregate = new PerformanceLoggerCountingAggregate(); }
@Override public void printPerformanceLog(PerformanceLogger logger) { String s = ""; for (Entry<String, Long> e : logger.getLoggedValues().entrySet()) { s += "[" + e.getKey().toString() + ": " + e.getValue().toString() + "]"; } LoggerFactory.getLogger(logger.getClass()).info(s); } }
@Override public Map<String, Long> getLoggedValues() { return aggregate.getLoggedValues(); } }
@Override public void reset() { aggregate.reset(); }
@Test public void testOpen() throws Exception { runTest(new FieldBoolTests.TestOpen<>(), EvaluationStrategy.SEQUENTIAL_BATCHED, true); assertThat(performanceLoggers.get(1).get(0).getLoggedValues().get(NetworkLoggingDecorator.NETWORK_TOTAL_BYTES), is((long)4)); }
@Test public void test_ss_division() { runTest(new DivisionTests.TestDivision<>(), new TestParameters().performanceLogging(true)); assertThat(performanceLoggers.get(1).getLoggedValues() .get(ComparisonLoggerDecorator.ARITHMETIC_COMPARISON_COMP0), is((long) 80)); }