def speed_avrolight_write(): gc.disable() schema, value = SCHEMAS_TO_VALIDATE[-1] parsed_schema = json.loads(schema) for _ in timeit("avrolight, writing"): avrolight.write(parsed_schema, io.BytesIO(), value)
def test_write(): import avro.schema for schema, value in SCHEMAS_TO_VALIDATE: bytes = avro_write_datum(value, avro.schema.Parse(schema)) schema = json.loads(schema) fp = io.BytesIO() avrolight.write(schema, fp, value) assert_that(fp.getvalue(), equal_to(bytes))
def speed_avrolight_read(): gc.disable() schema, value = SCHEMAS_TO_VALIDATE[-1] parsed_schema = avrolight.Schema(json.loads(schema)) buffer = io.BytesIO() avrolight.write(parsed_schema, buffer, value) for _ in timeit("avrolight, reading"): avrolight.read(parsed_schema, buffer.getvalue())
def serialize(client, schema, message): schema_hash = client.put(schema) out = io.BytesIO() out.write(schema_hash) avrolight.write(schema, out, message) return out.getvalue()