tmf.ctf: Accelerate ByteArrayDefintion parsing
authorMatthew Khouzam <matthew.khouzam@ericsson.com>
Thu, 16 Jul 2015 01:31:57 +0000 (21:31 -0400)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 18 Dec 2015 16:05:44 +0000 (11:05 -0500)
Make BADs no longer need to generate definitions uselessly.

This patch yields a 15-50% acceleration in Synchronization benchmarks,
a 5% acceleration in the Kernel Analysis benchmark, and an average event
size reduction of 33%.

Change-Id: Ie581abaecf1d8b188de9f1acc3010fe3f7a65d7a
Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-on: https://git.eclipse.org/r/52024
Reviewed-by: Hudson CI
Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com>
ctf/org.eclipse.tracecompass.ctf.core/src/org/eclipse/tracecompass/internal/ctf/core/event/types/ByteArrayDefinition.java
ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEventField.java

index abc0f334df0e0f4dd9a0514a27c30de346d3ede4..4964bfed45b42d3b150610c5313dc3e24a6f764a 100644 (file)
@@ -109,4 +109,14 @@ public final class ByteArrayDefinition extends AbstractArrayDefinition {
         b.append(']');
         return checkNotNull(b.toString());
     }
+
+    /**
+     * Get a byte of the byte array
+     * @param index the index of the byte
+     *
+     * @return the byte
+     */
+    public byte getByte(int index) {
+        return fContent[index];
+    }
 }
\ No newline at end of file
index b891bc1da21799a821d96fb88f059dd62e327f5a..d6a0bdd2d07a869f94fe524cab8e7f091083b9b3 100644 (file)
@@ -21,7 +21,6 @@ import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull;
 
 import java.util.ArrayList;
 import java.util.Arrays;
-import java.util.Collection;
 import java.util.List;
 
 import org.eclipse.jdt.annotation.NonNull;
@@ -37,6 +36,7 @@ import org.eclipse.tracecompass.ctf.core.event.types.IntegerDeclaration;
 import org.eclipse.tracecompass.ctf.core.event.types.IntegerDefinition;
 import org.eclipse.tracecompass.ctf.core.event.types.StringDefinition;
 import org.eclipse.tracecompass.ctf.core.event.types.VariantDefinition;
+import org.eclipse.tracecompass.internal.ctf.core.event.types.ByteArrayDefinition;
 import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
 import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
 import org.eclipse.tracecompass.tmf.ctf.core.CtfEnumPair;
@@ -130,8 +130,20 @@ public abstract class CtfTmfEventField extends TmfEventField {
             }
             CompoundDeclaration arrDecl = (CompoundDeclaration) decl;
             IDeclaration elemType = null;
-            Collection<Definition> definitions = arrayDef.getDefinitions();
             elemType = arrDecl.getElementType();
+            if (arrayDef instanceof ByteArrayDefinition) {
+                ByteArrayDefinition byteArrayDefinition = (ByteArrayDefinition) arrayDef;
+                /* it's a CTFIntegerArrayField */
+                int size = arrayDef.getLength();
+                long[] values = new long[size];
+                for (int i = 0; i < size; i++) {
+                    values[i] = Byte.toUnsignedLong(byteArrayDefinition.getByte(i));
+                }
+                field = new CTFIntegerArrayField(fieldName, values,
+                        16,
+                        false);
+
+            }
             if (elemType instanceof IntegerDeclaration) {
                 /*
                  * Array of integers => CTFIntegerArrayField, unless it's a
@@ -144,7 +156,7 @@ public abstract class CtfTmfEventField extends TmfEventField {
                     field = new CTFStringField(fieldName, arrayDef.toString());
                 } else {
                     /* it's a CTFIntegerArrayField */
-                    int size = arrayDef.getDefinitions().size();
+                    int size = arrayDef.getLength();
                     long[] values = new long[size];
                     for (int i = 0; i < size; i++) {
                         IDefinition elem = arrayDef.getDefinitions().get(i);
@@ -162,6 +174,7 @@ public abstract class CtfTmfEventField extends TmfEventField {
                 CtfTmfEventField[] elements = new CtfTmfEventField[arrayDef.getLength()];
                 /* Parse the elements of the array. */
                 int i = 0;
+                List<Definition> definitions = arrayDef.getDefinitions();
                 for (IDefinition definition : definitions) {
                     CtfTmfEventField curField = CtfTmfEventField.parseField(
                             definition, fieldName + '[' + i + ']');
This page took 0.02883 seconds and 5 git commands to generate.