Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tXml to benchmark #1

Open
strarsis opened this issue Sep 7, 2020 · 4 comments
Open

Add tXml to benchmark #1

strarsis opened this issue Sep 7, 2020 · 4 comments

Comments

@strarsis
Copy link

strarsis commented Sep 7, 2020

Just found a new, maintained XML parser in native JavaScript: https://github.com/TobiasNickel/tXml

and probably the fastest xml parser in pure javascript.

Would be interesting to know!

@Redsandro
Copy link
Owner

Redsandro commented Sep 7, 2020

Thanks for the heads up @strarsis.

A good parser creates an object where any value can be accessed directly (dot notation) without loops and iterative searches.

I cannot do a fair comparison because tXml throws children in a hard to traverse array inception twice as big as the other libraries. While "parsing" is faster, this makes "searching" the final object slower, which is subjectively unreasonable because this test assumes you parse once but query the final data object many times.

All five libraries in this test create an object where any child can be accessed directly by key, and they are configurable in a way so that they are compatible drop-in replacements for each other. With tXml, you need to traverse children to find a particular key.

For tXml to be added to this test (and be a useful drop-in replacement for all the projects that use one of the five tested libraries), it will need to be altered to accept options that generate identical output.

E.g. in stead of this tXml output:

[
  "children": [
    {
      "tagName": "child1",
      "attributes": {},
      "children": [
        {
          "tagName": "child2",
          "attributes": {},
          "children": [
            {
              "tagName": "child3",
              "attributes": {},
              "children": [
                "tagName": "child4",
                // ...

The target object should follow the common structure:

{
  "child1": {
    "@": {},
    "child2": {
      "@": {},
      "child3": {
        "@": {},
        "child4": [
          // ...

If that's done and it's still fast, it becomes a helluva lot more useful. 💯

@strarsis
Copy link
Author

strarsis commented Sep 7, 2020

@Redsandro: Thanks for your test!
There are some 'simplify' methods and streaming support - would this help constructing the object?

@Redsandro
Copy link
Owner

@strarsis I had a quick look, but I can't use it in that way. Perhaps if @TobiasNickel would be interested in adding the options to write the object in a way similar to the other libraries.

@strarsis
Copy link
Author

strarsis commented Sep 7, 2020

@Redsandro: That's great! What I like about that library is that it is native JS (and its speed claim, well, to be tested).
Also its streaming feature allows better replacement of existing libraries in tools that use another stream-solution (like sax).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants