@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 void reset() { for (PerformanceLogger performanceLogger : performanceLoggers) { performanceLogger.reset(); } }
Map<String, Long> loggedValues = performanceLogger.getLoggedValues(); assertThat(loggedValues.get(BatchEvaluationLoggingDecorator.BATCH_COUNTER), is((long) 8)); assertThat(loggedValues.get(BatchEvaluationLoggingDecorator.BATCH_NATIVE_PROTOCOLS), is((long) 21)); performanceLogger.reset(); loggedValues = performanceLogger.getLoggedValues(); assertThat(loggedValues.get(BatchEvaluationLoggingDecorator.BATCH_COUNTER), is((long) 0)); assertThat(loggedValues.get(BatchEvaluationLoggingDecorator.BATCH_NATIVE_PROTOCOLS),
PerformanceLogger pl = performanceLoggers.get(id); Map<String, Long> loggedValues = pl.getLoggedValues(); assertThat(loggedValues.get(BinaryComparisonLoggingDecorator.BINARY_COMPARISON_GT), is(amountOfGts)); is(amountOfEqsInTest)); pl.reset(); loggedValues = pl.getLoggedValues(); assertThat(loggedValues.get(BinaryComparisonLoggingDecorator.BINARY_COMPARISON_GT), is((long) 0));
Map<String, Long> loggedValues = performanceLogger.getLoggedValues(); assertThat(loggedValues.get(NetworkLoggingDecorator.NETWORK_TOTAL_BYTES), is(130L)); assertThat(loggedValues.get(NetworkLoggingDecorator.NETWORK_TOTAL_BATCHES), is(2L)); assertThat(loggedValues.get(NetworkLoggingDecorator.NETWORK_PARTY_BYTES + "_1"), is(130L)); performanceLogger.reset(); loggedValues = performanceLogger.getLoggedValues(); assertThat(loggedValues.get(NetworkLoggingDecorator.NETWORK_TOTAL_BYTES), is(0L)); assertThat(loggedValues.get(NetworkLoggingDecorator.NETWORK_TOTAL_BATCHES), is(0L));
@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); } }
Map<String, Long> loggedValues = pl.getLoggedValues(); assertThat(loggedValues.get(BinaryLoggingDecorator.BINARY_BASIC_XOR), is(amountOfXorsInTest)); assertThat(loggedValues.get(BinaryLoggingDecorator.BINARY_BASIC_AND), is(amountOfAndsInTest)); assertThat(loggedValues.get(BinaryLoggingDecorator.BINARY_BASIC_RANDOM), is((long) 0)); pl.reset(); loggedValues = pl.getLoggedValues(); assertThat(loggedValues.get(BinaryLoggingDecorator.BINARY_BASIC_XOR), is((long) 0)); assertThat(loggedValues.get(BinaryLoggingDecorator.BINARY_BASIC_AND), is((long) 0));
@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)); }
Map<String, Long> loggedValues = performanceLogger.getLoggedValues(); long runningTime = loggedValues.get(EvaluatorLoggingDecorator.SCE_RUNNINGTIMES + 0); assertTrue(runningTime > 0); performanceLogger.reset(); loggedValues = performanceLogger.getLoggedValues(); assertTrue(loggedValues.size() == 0);
@Test public void test_basic_logic() throws Exception { runTest(new BasicBooleanTests.TestInput<>(true), EvaluationStrategy.SEQUENTIAL, true); runTest(new BasicBooleanTests.TestInputDifferentSender<>(true), EvaluationStrategy.SEQUENTIAL, true, 2); runTest(new BasicBooleanTests.TestXOR<>(true), EvaluationStrategy.SEQUENTIAL, true); runTest(new BasicBooleanTests.TestAND<>(true), EvaluationStrategy.SEQUENTIAL, true); runTest(new BasicBooleanTests.TestNOT<>(true), EvaluationStrategy.SEQUENTIAL, true); runTest(new BasicBooleanTests.TestRandomBit<>(true), EvaluationStrategy.SEQUENTIAL, true); assertThat(performanceLoggers.get(1).get(2).getLoggedValues().get(BinaryLoggingDecorator.BINARY_BASIC_XOR), is((long)4)); assertThat(performanceLoggers.get(1).get(3).getLoggedValues().get(BinaryLoggingDecorator.BINARY_BASIC_AND), is((long)4)); assertThat(performanceLoggers.get(1).get(5).getLoggedValues().get(BinaryLoggingDecorator.BINARY_BASIC_RANDOM), is((long)1)); }
PerformanceLogger pl = performanceLoggers.get(id); Map<String, Long> loggedValues = pl.getLoggedValues(); assertThat(loggedValues.get(BinaryComparisonLoggingDecorator.BINARY_COMPARISON_GT), is((long) 0)); is((long) 2)); pl.reset(); loggedValues = pl.getLoggedValues(); assertThat(loggedValues.get(BinaryComparisonLoggingDecorator.BINARY_COMPARISON_GT), is((long) 0));
@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)); }
PerformanceLogger pl = performanceLoggers.get(pId); Map<String, Long> loggedValues = pl.getLoggedValues(); assertThat(loggedValues.get(NumericLoggingDecorator.ARITHMETIC_BASIC_ADD), is((long) 1)); assertThat(loggedValues.get(NumericLoggingDecorator.ARITHMETIC_BASIC_MULT), is((long) 1)); assertThat(loggedValues.get(NumericLoggingDecorator.ARITHMETIC_BASIC_RAND), is((long) 0)); pl.reset(); loggedValues = pl.getLoggedValues(); assertThat(loggedValues.get(NumericLoggingDecorator.ARITHMETIC_BASIC_ADD), is((long) 0)); assertThat(loggedValues.get(NumericLoggingDecorator.ARITHMETIC_BASIC_MULT), is((long) 0));
@Test public void test_Minimum_Protocol_2_parties() { runTest(new MinTests.TestMinimumProtocol<>(), new TestParameters() .numParties(2) .performanceLogging(true)); assertThat(performanceLoggers.get(1).getLoggedValues() .get(ComparisonLoggerDecorator.ARITHMETIC_COMPARISON_LEQ), is((long) 10)); }
new DefaultPerformancePrinter().printPerformanceLog(logger); Map<String, Long> loggedValues = logger.getLoggedValues(); assertThat(loggedValues.get(ComparisonLoggerDecorator.ARITHMETIC_COMPARISON_EQ), is((long) 2)); is((long) 2)); logger.reset(); loggedValues = logger.getLoggedValues(); assertThat(loggedValues.get(ComparisonLoggerDecorator.ARITHMETIC_COMPARISON_EQ), is((long) 0));
@Test public void test_OutputToTarget_Sequential() { runTest(new BasicArithmeticTests.TestOutputToSingleParty<>(), new TestParameters() .numParties(2) .performanceLogging(true)); assertThat(performanceLoggers.get(1).getLoggedValues() .get(NetworkLoggingDecorator.NETWORK_TOTAL_BYTES), is((long) 0)); }
@Test public void test_LpSolverBland() { runTest(new LpBuildingBlockTests.TestLpSolver<>(LPSolver.PivotRule.BLAND), new TestParameters().numParties(2).performanceLogging(true)); assertThat(performanceLoggers.get(1).getLoggedValues() .get(ComparisonLoggerDecorator.ARITHMETIC_COMPARISON_EQ), is((long) 33)); }
@Test public void test_Exponentiation() { runTest(new ExponentiationTests.TestExponentiation<>(), new TestParameters().numParties(2).performanceLogging(true)); assertThat(performanceLoggers.get(1).getLoggedValues() .get(NumericLoggingDecorator.ARITHMETIC_BASIC_SUB), is((long) 19)); }
@Test public void test_Min_Inf_Frac_2_parties() { runTest(new MinTests.TestMinInfFraction<>(), new TestParameters() .numParties(2) .performanceLogging(true)); assertThat(performanceLoggers.get(1).getLoggedValues() .get(ComparisonLoggerDecorator.ARITHMETIC_COMPARISON_LEQ), is((long) 10)); }