Skip to content

Commit 010fb7b

Browse files
committed
Updates README and benchmarks
1 parent afc3867 commit 010fb7b

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

README.md

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ end
5757

5858
Unwraps binary string from UTF-8 compatible encoding.
5959

60-
* `msgpack.ByteArray.new(blob: string): msgpack.ByteArray`
61-
62-
Wraps a string value in order to represent MessagePack `bin` datatype.
63-
64-
* `msgpack.Extension.new(extensionType: number, blob: string): msgpack.Extension`
60+
* `msgpack.Extension.new(extensionType: number, blob: buffer): msgpack.Extension`
6561

6662
Create MessagePack extension type, which is used for custom datatype serialization purposes.
6763
First argument `extensionType` must be an integer.
@@ -92,7 +88,10 @@ To benchmark module's encoding performance same data is used as previously.
9288
It is first decoded as table structure then both `msgpack.encode` and `JSONEncode` encode it with the following results:
9389
![Figure with JSONEncode and msgpack.encode benchmark results](./assets/encode-benchmark.png)
9490

95-
MessagePack encoder is bit less consistent as `JSONEncode`, but on average `msgpack.encode` is as performant as `JSONEncode`.
91+
After transitioning to Luau buffer based encoding strategy, MessagePack encoder significantly exceeds the performance of the `JSONEncode` function.
92+
An interesting observation can be made on how consistent is it's execution time, even in comparision with the `msgpack.decode`.
93+
This is most likely is because `msgpack.encode` performs only a single dynamic allocation by computing the nescessary amount of bytes to encode the data and then allocates the result buffer in one go.
94+
9695
Here is another benchmark which combines both decoding and encoding steps and as it can be seen, thanks to much greater `msgpack.decode` speed, both methods together perform better than built-in `JSONEncode` and `JSONDecode`:
9796
![Figure with "JSONEncode & JSONDecode" and "msgpack.encode & msgpack.decode" benchmark results](./assets/decode-encode-benchmark.png)
9897

assets/decode-benchmark.png

9.48 KB
Loading

assets/decode-encode-benchmark.png

5.1 KB
Loading

assets/encode-benchmark.png

992 Bytes
Loading

0 commit comments

Comments
 (0)