Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions example/speed_test_uint32_array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#include <msgpack.h>
#include <assert.h>

void test()
{
size_t size = 10000000;
msgpack_sbuffer buf;
msgpack_sbuffer_init(&buf);

msgpack_packer * pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);

msgpack_pack_array(pk, size);
{
int idx = 0;
for (; idx < size; ++idx)
msgpack_pack_uint32(pk, 1);
}
msgpack_packer_free(pk);


size_t upk_pos = 0;
msgpack_unpacked msg;
msgpack_unpacked_init(&msg);

while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
}

msgpack_sbuffer_destroy(&buf);
}

int main(int argc, char **argv)
{
int i = 0;
for (; i < 10; ++i) test();
return 0;
}
37 changes: 37 additions & 0 deletions example/speed_test_uint64_array.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include <msgpack.h>
#include <assert.h>

void test()
{
uint64_t test_u64 = 0xFFF0000000000001LL;
size_t size = 10000000;
msgpack_sbuffer buf;
msgpack_sbuffer_init(&buf);

msgpack_packer * pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);

msgpack_pack_array(pk, size);
{
int idx = 0;
for (; idx < size; ++idx)
msgpack_pack_uint64(pk, test_u64);
}
msgpack_packer_free(pk);


size_t upk_pos = 0;
msgpack_unpacked msg;
msgpack_unpacked_init(&msg);

while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos)) {
}

msgpack_sbuffer_destroy(&buf);
}

int main(int argc, char **argv)
{
int i = 0;
for (; i < 10; ++i) test();
return 0;
}
18 changes: 18 additions & 0 deletions test/msgpackc_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,3 +502,21 @@ TEST(MSGPACKC, unpack_bin32)

msgpack_zone_destroy(&z);
}

TEST(MSGPACKC, unpack_array_uint64)
{
const char buf[] = {
(char)0x91, (char)0xcf, (char)0xff, (char)0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01
};
msgpack_zone z;
msgpack_zone_init(&z, 2048);
msgpack_object obj;
msgpack_unpack_return ret;
ret = msgpack_unpack(buf, sizeof(buf), NULL, &z, &obj);
EXPECT_EQ(MSGPACK_UNPACK_SUCCESS, ret);
EXPECT_EQ(MSGPACK_OBJECT_ARRAY, obj.type);
EXPECT_EQ(1, obj.via.array.size);
EXPECT_EQ(MSGPACK_OBJECT_POSITIVE_INTEGER, obj.via.array.ptr[0].type);
EXPECT_EQ(0xFFF0000000000001LL, obj.via.array.ptr[0].via.u64);
msgpack_zone_destroy(&z);
}