<script crossorigin src="https://unpkg.com/@msgpack/msgpack"></script>
var data = {"glossary":{"title":"example glossary","GlossDiv":{"title":"S","GlossList":{"GlossEntry":{"ID":"SGML","SortAs":"SGML","GlossTerm":"Standard Generalized Markup Language","Acronym":"SGML","Abbrev":"ISO 8879:1986","GlossDef":{"para":"A meta-markup language, used to create markup languages such as DocBook.","GlossSeeAlso":["GML","XML"]},"GlossSee":"markup"}}}}};
var buf = JSON.stringify(data);
var result = MessagePack.decode(buf);
var result = JSON.parse(buf);
--enable-precise-memory-info
flag.
Test case name | Result |
---|---|
MessagePack.encode | |
JSON.parse |
Test name | Executions per second |
---|---|
MessagePack.encode | 0.0 Ops/sec |
JSON.parse | 780545.8 Ops/sec |
Let's break down the provided benchmark definition and test cases.
What is being tested?
The website MeasureThat.net provides a microbenchmarking platform where users can create and run JavaScript benchmarks. In this case, two individual test cases are comparing the performance of MessagePack encode and JSON parse.
Options compared:
MessagePack.encode()
function is used to serialize data into a MessagePack buffer.JSON.parse()
function is used to parse a JSON string into a JavaScript object.Pros and Cons of each approach:
MessagePack Encode:
JSON Parse:
Library:
Special JS feature or syntax:
None mentioned directly; however, this benchmark assumes a basic understanding of JavaScript's string manipulation methods like JSON.stringify()
and decode()
, as well as its array handling methods like [ ]
.
Other alternatives:
In summary, this benchmark tests the performance of MessagePack encode against JSON parse. The results will help users compare the execution speeds of these two serialization formats in JavaScript applications.