Good morning all,
I\'m searching for a very fast binary serialization technique for c++. I only need to serialize data contained in objects (no pointers etc.). I\'d like
Because I/O is most likely to be the bottleneck a compact format may help. Out of curiosity I tried the following Colfer scheme compiled as colf -s 16 C
.
package data
type item struct {
off uint64
size uint32
}
... with a comparable C test:
clock_t start = clock();
data_item data;
void* buf = malloc(colfer_size_max);
FILE* fd = fopen( "test.colfer.dat", "wb" );
for ( long i = 0; i < tests; i++ )
{
data.off = i;
data.size = i & 0xFFFF;
size_t n = data_item_marshal( &data, buf );
fwrite( buf, n, 1, fd );
}
fclose( fd );
clock_t stop = clock();
The results are quite disappointing on SSD despite the fact that the serial size is 40% smaller in comparison to the raw struct dumps.
colfer took 0.520 seconds
plain took 0.320 seconds
Since the generated code is pretty fast it seems unlikely you'll win anything with serialization libraries.