Efficiency JSON vs Delimited String in Javascript -


I am currently working in the zero MQ with the node. ZeroMac allows for a message in the form of a string between the applications. The application will be processed on thousands of messages.

Will be faster to parse the delimited string:

  "foo bar baz" .split ('');   

or the Stretpted JSON object:

  JSON.parse ('{"a": "foo", "b": "bar", "c ":" Baz "});   

How to test the efficiency of each (speed and memory) in each Node.js and / or browser.

= "text">

You have chromium for Chrome or Linux) You can use something similar to the following code: // open the first inspector ** ctrl + shift + i ** Then write the code Switch to the Console tab for / or you want to open the `Tools & gt; Developer Tools` then select the console tab / code here: console.time ('t1'); "Foo Bar Barge" .split (''); Console.timeEnd ('t1'); // result t1: 0.020ms console.time ('t2'); // Here you instruct JSON.parse ('{"a": "foo", "b": "bar", "c": "baz"}); Console.timeEnd ('t2'); // Results T2: 0.046ms

It is clear that the first method is faster than the other side

Note : Object To convert the string to JSON format, you must put both the property and its value in "Our case" for example under ""

:

A: "foo" "b": should be "a": "foo"

b: "bar" and so on

so that the entire string ( Ctimel>

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -