mirror of
https://github.com/msgpack/msgpack-c.git
synced 2025-10-18 19:48:46 +02:00
move exmple/c/* to example/
example/c/cmake/CMakeLists.txt => example/cmake/CMakeLists.txt example/c/lib_buffer_unpack.c => example/lib_buffer_unpack.c example/c/simple_c.c => example/simple_c.c example/c/speed_test_uint32_array.c => example/speed_test_uint32_array.c example/c/speed_test_uint64_array.c => example/speed_test_uint64_array.c example/c/user_buffer_unpack.c => example/user_buffer_unpack.c Use `git log --follow example/filename` to see full log
This commit is contained in:
36
example/speed_test_uint32_array.c
Normal file
36
example/speed_test_uint32_array.c
Normal file
@@ -0,0 +1,36 @@
|
||||
#include <msgpack.h>
|
||||
|
||||
void test()
|
||||
{
|
||||
size_t size = 10000000;
|
||||
msgpack_sbuffer buf;
|
||||
msgpack_packer * pk;
|
||||
size_t upk_pos = 0;
|
||||
msgpack_unpacked msg;
|
||||
|
||||
msgpack_sbuffer_init(&buf);
|
||||
|
||||
pk = msgpack_packer_new(&buf, msgpack_sbuffer_write);
|
||||
|
||||
msgpack_pack_array(pk, size);
|
||||
{
|
||||
size_t idx = 0;
|
||||
for (; idx < size; ++idx)
|
||||
msgpack_pack_uint32(pk, 1);
|
||||
}
|
||||
msgpack_packer_free(pk);
|
||||
|
||||
msgpack_unpacked_init(&msg);
|
||||
|
||||
while (msgpack_unpack_next(&msg, buf.data, buf.size, &upk_pos) == MSGPACK_UNPACK_SUCCESS) {
|
||||
}
|
||||
|
||||
msgpack_sbuffer_destroy(&buf);
|
||||
}
|
||||
|
||||
int main(void)
|
||||
{
|
||||
int i = 0;
|
||||
for (; i < 10; ++i) test();
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user