Skip to content

Improve performance #67

Description

@repeatedly

msgpack-d has a room for performance improvement.

http://forum.dlang.org/thread/tbugssjmjkliynevgvwm@forum.dlang.org

From above thread, cerealed has similar performance with msgpack-d.
I use modified benchmark script which adds more types.

import std.stdio;
import std.conv;
import std.datetime;
import std.algorithm;
import std.array;
import cerealed;
import msgpack;


struct Struct {
    bool b;
    int i;
    double d;
    string s;
    string[string] aa;
    int[] a;
}

Struct testStruct;

void withCerealed() {
    auto enc = Cerealiser();
    enc ~= testStruct;
    enc.cerealise!((bytes){});
    auto s = Decerealiser(enc.bytes).value!Struct;
    assert(s == testStruct);
}

void withMsgPack() {
    auto bytes = pack(testStruct);
    auto s = bytes.unpack!Struct;
    assert(s == testStruct);
}

void main() {
    testStruct = Struct(true, 5, 3.14, "hi there, nice to meet you!", ["leindex": "levalue"], new int[](20));
    auto results = benchmark!(withCerealed, withMsgPack)(1_000_000);
    writeln("Cerealed: ", to!Duration(results[0]));
    writeln("MsgPack:  ", to!Duration(results[1]));
}

On my MacBook result:

dmd 2.0.68.0 with -inline -release -boundscheck=off:

Cerealed: 3 secs, 12 ms, 667 μs, and 5 hnsecs
MsgPack:  2 secs, 39 ms, 340 μs, and 2 hnsecs

ldc2-0.15.2-beta2 with -O3 -inline -release:
Cerealed: 2 secs, 205 ms, and 873 μs
MsgPack:  1 sec, 377 ms, 916 μs, and 6 hnsecs

I will check memory usage later.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions