From c6044fe4e9bed80af81b2b8a1b845cfd490d27ce Mon Sep 17 00:00:00 2001 From: mikera Date: Mon, 7 Oct 2024 09:55:41 +0100 Subject: [PATCH] Encoding speed trials --- .../convex/core/examples/EncodingTrials.java | 71 +++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 convex-core/src/test/java/convex/core/examples/EncodingTrials.java diff --git a/convex-core/src/test/java/convex/core/examples/EncodingTrials.java b/convex-core/src/test/java/convex/core/examples/EncodingTrials.java new file mode 100644 index 000000000..17932c006 --- /dev/null +++ b/convex-core/src/test/java/convex/core/examples/EncodingTrials.java @@ -0,0 +1,71 @@ +package convex.core.examples; + +import java.util.List; + +import convex.core.cvm.State; +import convex.core.data.ACell; +import convex.core.data.Blob; +import convex.core.data.Format; +import convex.core.data.Refs; +import convex.core.exceptions.BadFormatException; +import convex.core.init.Init; +import convex.core.text.Text; +import convex.test.Samples; + +/** + * Test class for encoding speed + */ +public class EncodingTrials { + + // Data file (printout of a genesis CVM state) + static State s=Init.createState(List.of(Samples.KEY_PAIR.getAccountKey())); + + public static void main(String[] args) throws BadFormatException { + System.out.println("State dumps"); + runTrial(s,100); + runTrial(s,100); + runTrial(s,100); + runTrial(s,100); + runTrial(s,100); + + System.out.println("State reaps"); + runTrial2(s,100); + runTrial2(s,100); + runTrial2(s,100); + runTrial2(s,100); + runTrial2(s,100); + + } + + @SuppressWarnings("unused") + private static void runTrial(ACell data, long REPS) { + long start=System.nanoTime(); + Blob warmUp=Format.encodeMultiCell(data,true); + long len=warmUp.count(); + long cellCount=Refs.totalRefCount(s); + for (int i=0; i