Skip to content

Commit

Permalink
Merge pull request #54 from ess-dmsc/performance_fix_f142
Browse files Browse the repository at this point in the history
Improve f142 serialisation performance
  • Loading branch information
mattclarke authored Jan 3, 2022
2 parents 13a9925 + fb8ce5b commit efef4af
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 51 deletions.
2 changes: 1 addition & 1 deletion streaming_data_types/_version.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version is not directly defined in __init__ because that causes all
# run time dependencies to become build-time dependencies when it is
# imported in setup.py
version = "0.15.0"
version = "0.15.1"
60 changes: 10 additions & 50 deletions streaming_data_types/logdata_f142.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
ArrayUByteStart,
ArrayUByteAddValue,
ArrayUByteEnd,
ArrayUByteStartValueVector,
)
from streaming_data_types.fbschemas.logdata_f142.Byte import (
Byte,
Expand All @@ -25,7 +24,6 @@
ArrayByteStart,
ArrayByteAddValue,
ArrayByteEnd,
ArrayByteStartValueVector,
)
from streaming_data_types.fbschemas.logdata_f142.UShort import (
UShort,
Expand All @@ -38,7 +36,6 @@
ArrayUShortStart,
ArrayUShortAddValue,
ArrayUShortEnd,
ArrayUShortStartValueVector,
)
from streaming_data_types.fbschemas.logdata_f142.Short import (
Short,
Expand All @@ -51,7 +48,6 @@
ArrayShortStart,
ArrayShortAddValue,
ArrayShortEnd,
ArrayShortStartValueVector,
)
from streaming_data_types.fbschemas.logdata_f142.UInt import (
UInt,
Expand All @@ -64,7 +60,6 @@
ArrayUIntStart,
ArrayUIntAddValue,
ArrayUIntEnd,
ArrayUIntStartValueVector,
)
from streaming_data_types.fbschemas.logdata_f142.Int import (
Int,
Expand All @@ -77,7 +72,6 @@
ArrayIntStart,
ArrayIntAddValue,
ArrayIntEnd,
ArrayIntStartValueVector,
)
from streaming_data_types.fbschemas.logdata_f142.ULong import (
ULong,
Expand All @@ -90,7 +84,6 @@
ArrayULongStart,
ArrayULongAddValue,
ArrayULongEnd,
ArrayULongStartValueVector,
)
from streaming_data_types.fbschemas.logdata_f142.Long import (
Long,
Expand All @@ -103,7 +96,6 @@
ArrayLongStart,
ArrayLongAddValue,
ArrayLongEnd,
ArrayLongStartValueVector,
)
from streaming_data_types.fbschemas.logdata_f142.Float import (
Float,
Expand All @@ -116,7 +108,6 @@
ArrayFloatStart,
ArrayFloatAddValue,
ArrayFloatEnd,
ArrayFloatStartValueVector,
)
from streaming_data_types.fbschemas.logdata_f142.Double import (
Double,
Expand All @@ -129,7 +120,6 @@
ArrayDoubleStart,
ArrayDoubleAddValue,
ArrayDoubleEnd,
ArrayDoubleStartValueVector,
)
from streaming_data_types.fbschemas.logdata_f142.String import (
String,
Expand Down Expand Up @@ -191,10 +181,7 @@ def _serialise_byte(builder: flatbuffers.Builder, data: np.ndarray, source: int)


def _serialise_bytearray(builder: flatbuffers.Builder, data: np.ndarray, source: int):
ArrayByteStartValueVector(builder, len(data))
for single_value in reversed(data):
builder.PrependInt8(single_value)
array_offset = builder.EndVector(len(data))
array_offset = builder.CreateNumpyVector(data)
ArrayByteStart(builder)
ArrayByteAddValue(builder, array_offset)
value_position = ArrayByteEnd(builder)
Expand All @@ -215,10 +202,7 @@ def _serialise_ubyte(builder: flatbuffers.Builder, data: np.ndarray, source: int


def _serialise_ubytearray(builder: flatbuffers.Builder, data: np.ndarray, source: int):
ArrayUByteStartValueVector(builder, len(data))
for single_value in reversed(data):
builder.PrependUint8(single_value)
array_offset = builder.EndVector(len(data))
array_offset = builder.CreateNumpyVector(data)
ArrayUByteStart(builder)
ArrayUByteAddValue(builder, array_offset)
value_position = ArrayUByteEnd(builder)
Expand All @@ -239,10 +223,7 @@ def _serialise_short(builder: flatbuffers.Builder, data: np.ndarray, source: int


def _serialise_shortarray(builder: flatbuffers.Builder, data: np.ndarray, source: int):
ArrayShortStartValueVector(builder, len(data))
for single_value in reversed(data):
builder.PrependInt16(single_value)
array_offset = builder.EndVector(len(data))
array_offset = builder.CreateNumpyVector(data)
ArrayShortStart(builder)
ArrayShortAddValue(builder, array_offset)
value_position = ArrayShortEnd(builder)
Expand All @@ -263,10 +244,7 @@ def _serialise_ushort(builder: flatbuffers.Builder, data: np.ndarray, source: in


def _serialise_ushortarray(builder: flatbuffers.Builder, data: np.ndarray, source: int):
ArrayUShortStartValueVector(builder, len(data))
for single_value in reversed(data):
builder.PrependUint16(single_value)
array_offset = builder.EndVector(len(data))
array_offset = builder.CreateNumpyVector(data)
ArrayUShortStart(builder)
ArrayUShortAddValue(builder, array_offset)
value_position = ArrayUShortEnd(builder)
Expand All @@ -287,10 +265,7 @@ def _serialise_int(builder: flatbuffers.Builder, data: np.ndarray, source: int):


def _serialise_intarray(builder: flatbuffers.Builder, data: np.ndarray, source: int):
ArrayIntStartValueVector(builder, len(data))
for single_value in reversed(data):
builder.PrependInt32(single_value)
array_offset = builder.EndVector(len(data))
array_offset = builder.CreateNumpyVector(data)
ArrayIntStart(builder)
ArrayIntAddValue(builder, array_offset)
value_position = ArrayIntEnd(builder)
Expand All @@ -311,10 +286,7 @@ def _serialise_uint(builder: flatbuffers.Builder, data: np.ndarray, source: int)


def _serialise_uintarray(builder: flatbuffers.Builder, data: np.ndarray, source: int):
ArrayUIntStartValueVector(builder, len(data))
for single_value in reversed(data):
builder.PrependUint32(single_value)
array_offset = builder.EndVector(len(data))
array_offset = builder.CreateNumpyVector(data)
ArrayUIntStart(builder)
ArrayUIntAddValue(builder, array_offset)
value_position = ArrayUIntEnd(builder)
Expand All @@ -335,10 +307,7 @@ def _serialise_long(builder: flatbuffers.Builder, data: np.ndarray, source: int)


def _serialise_longarray(builder: flatbuffers.Builder, data: np.ndarray, source: int):
ArrayLongStartValueVector(builder, len(data))
for single_value in reversed(data):
builder.PrependInt64(single_value)
array_offset = builder.EndVector(len(data))
array_offset = builder.CreateNumpyVector(data)
ArrayLongStart(builder)
ArrayLongAddValue(builder, array_offset)
value_position = ArrayLongEnd(builder)
Expand All @@ -359,10 +328,7 @@ def _serialise_ulong(builder: flatbuffers.Builder, data: np.ndarray, source: int


def _serialise_ulongarray(builder: flatbuffers.Builder, data: np.ndarray, source: int):
ArrayULongStartValueVector(builder, len(data))
for single_value in reversed(data):
builder.PrependUint64(single_value)
array_offset = builder.EndVector(len(data))
array_offset = builder.CreateNumpyVector(data)
ArrayULongStart(builder)
ArrayULongAddValue(builder, array_offset)
value_position = ArrayULongEnd(builder)
Expand All @@ -383,10 +349,7 @@ def _serialise_float(builder: flatbuffers.Builder, data: np.ndarray, source: int


def _serialise_floatarray(builder: flatbuffers.Builder, data: np.ndarray, source: int):
ArrayFloatStartValueVector(builder, len(data))
for single_value in reversed(data):
builder.PrependFloat32(single_value)
array_offset = builder.EndVector(len(data))
array_offset = builder.CreateNumpyVector(data)
ArrayFloatStart(builder)
ArrayFloatAddValue(builder, array_offset)
value_position = ArrayFloatEnd(builder)
Expand All @@ -407,10 +370,7 @@ def _serialise_double(builder: flatbuffers.Builder, data: np.ndarray, source: in


def _serialise_doublearray(builder: flatbuffers.Builder, data: np.ndarray, source: int):
ArrayDoubleStartValueVector(builder, len(data))
for single_value in reversed(data):
builder.PrependFloat64(single_value)
array_offset = builder.EndVector(len(data))
array_offset = builder.CreateNumpyVector(data)
ArrayDoubleStart(builder)
ArrayDoubleAddValue(builder, array_offset)
value_position = ArrayDoubleEnd(builder)
Expand Down

0 comments on commit efef4af

Please sign in to comment.