Browse Source

JNI-115: "Performance of Engine/Adapter bad" - Test added

pull/2/head
heck 5 years ago
parent
commit
28dd9a8f9e
  1. 15
      test/java/foundation/pEp/jniadapter/test/Makefile
  2. 37
      test/java/foundation/pEp/jniadapter/test/jni115/Makefile
  3. 66
      test/java/foundation/pEp/jniadapter/test/jni115/TestAlice.java

15
test/java/foundation/pEp/jniadapter/test/Makefile

@ -11,7 +11,12 @@ run: compile
$(MAKE) -C jni91 run
$(MAKE) -C jni92 run
$(MAKE) -C jni94 run
$(MAKE) -C jni96 run
$(MAKE) -C jni98 run
$(MAKE) -C jni100 run
$(MAKE) -C jni111 run
$(MAKE) -C jni114 run
$(MAKE) -C jni115 run
compile:
$(MAKE) -C templateAlice compile
@ -22,7 +27,12 @@ compile:
$(MAKE) -C jni91 compile
$(MAKE) -C jni92 compile
$(MAKE) -C jni94 compile
$(MAKE) -C jni96 compile
$(MAKE) -C jni98 compile
$(MAKE) -C jni100 compile
$(MAKE) -C jni111 compile
$(MAKE) -C jni114 compile
$(MAKE) -C jni115 compile
clean:
$(MAKE) -C templateAlice clean
@ -33,7 +43,12 @@ clean:
$(MAKE) -C jni91 clean
$(MAKE) -C jni92 clean
$(MAKE) -C jni94 clean
$(MAKE) -C jni96 clean
$(MAKE) -C jni98 clean
$(MAKE) -C jni100 clean
$(MAKE) -C jni111 clean
$(MAKE) -C jni114 clean
$(MAKE) -C jni115 clean
clean-pep-home:
$(MAKE) -C basic clean-pep-home

37
test/java/foundation/pEp/jniadapter/test/jni115/Makefile

@ -0,0 +1,37 @@
include ../../../../../../../Makefile.conf
include ../Makefile.conf
TEST_UNIT_NAME=jni115
JAVA_CLASSES = \
TestAlice.class \
../utils/AdapterBaseTestContext.class \
../utils/AdapterTestUtils.class \
../utils/TestCallbacks.class
.PHONY: pitytest compile alice test clean
all: alice compile
pitytest:
$(MAKE) -C $(PITYTEST_DIR)
alice: compile clean-pep-home-alice
cd $(JAVA_CWD);pwd;HOME=$(JAVA_PEP_HOME_DIR_ALICE) $(JAVA) $(JAVA_PKG_BASENAME).$(TEST_UNIT_NAME).TestAlice
compile: $(JAVA_CLASSES) pitytest
%.class: %.java
cd $(JAVA_CWD);javac -cp $(CLASSPATH) $(JAVA_PKG_BASEPATH)/$(TEST_UNIT_NAME)/$<
clean:
rm -f $(JAVA_CLASSES)
rm -f *.class
rm -f *.log
rm -Rf .gnupg
rm -Rf .lldb
clean-pep-home: clean-pep-home-alice
clean-pep-home-alice:
rm -rf $(PEP_HOME_DIR_ALICE)/.pEp

66
test/java/foundation/pEp/jniadapter/test/jni115/TestAlice.java

@ -0,0 +1,66 @@
package foundation.pEp.jniadapter.test.jni115;
import static foundation.pEp.pitytest.TestLogger.*;
import foundation.pEp.jniadapter.Message;
import foundation.pEp.pitytest.*;
import foundation.pEp.pitytest.utils.TestUtils;
import foundation.pEp.jniadapter.test.utils.*;
import java.time.Duration;
import java.util.ArrayList;
import java.util.List;
class Jni115TestContext extends AdapterBaseTestContext {
public int messagesToBobCount = 1000;
public List<Message> messagesToBob = new ArrayList<>();
@Override
public void init() throws Throwable {
super.init();
for (int i = 0; i < messagesToBobCount; i++) {
Message tmp = AdapterTestUtils.makeNewTestMessage(alice, bob, Message.Direction.Outgoing);
tmp.setLongmsg(tmp.getLongmsg() + " nr: " + String.valueOf(i));
messagesToBob.add(tmp);
}
}
}
class TestAlice {
public static void main(String[] args) throws Exception {
TestSuite.getDefault().setVerbose(true);
TestSuite.getDefault().setTestColor(TestUtils.TermColor.GREEN);
Jni115TestContext ctx1 = new Jni115TestContext();
new TestUnit<Jni115TestContext>("myself()", ctx1, ctx -> {
ctx.alice = ctx.engine.myself(ctx.alice);
if (ctx.alice.fpr == null) {
throw new RuntimeException();
}
});
new TestUnit<Jni115TestContext>("importKey()", ctx1, ctx -> {
ctx.engine.importKey(ctx.keyBobPub);
});
new TestUnit<Jni115TestContext>("#MassEncryption", ctx1, ctx -> {
TestUtils.readKey();
log("Encrypting " + ctx.messagesToBobCount + " messages");
Duration total = new StopWatch(() -> {
for (Message msg : ctx.messagesToBob) {
Message encrypted = ctx.engine.encrypt_message(msg, null, Message.EncFormat.PEP);
logRaw(".");
}
}).getDuration();
logRaw("\n");
log("Total time [ms]: " + total.toMillis());
});
TestSuite.getDefault().run();
}
}
Loading…
Cancel
Save