-
Notifications
You must be signed in to change notification settings - Fork 91
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
Speed up the search-function #15
Comments
Thank you for the great work, its very easy to use with Xpath syntax. However, when my json data gets large, JSON.search() getting slow. Any recommendations to speed it up or restructure my Json format for better performance? |
Hi @duyhung85 I'll get back ASAP. Thanks |
@duyhung85 - I have created a benchmark branch. In this branch, I have tested, with Firefox, searches on a JSON structure, consisting of ~600 objects. Before the improvement, searching and finding all objects (XPath: '//*') took about 800ms. After the improvement code, the same search takes about 73-75ms. I'll explore more ways to make it even faster. In the mean time, it would be super if you can try out this branch, at least in your dev-environment and get back to me with feedback. Thanks |
Hi hbi99, Wow, its lightning speed JSON search Im getting here, like more than 10x faster. Before the update, its taking 500ms to scan my JSON structure (My Json is deep nested), now only 38ms-40ms. Superb! You made my day! Thanks, keep up the good work. |
@duyhung85 - thanks for catching the issue. Cheers |
Hi hbi99, I'm taking your code at defiantjs.com for example, the last one where you search JSON then update the original object. If i run it with the benchmark version (defiant.js-benchmark/dist/defiant-latest.min.js), it returns in console: I think it assigns the first new value to all of the elements, so my object elements are all identical after that. Cheers, |
@duyhung85 - great catch! As it turned out, the previous solution was no good...so I made a U-turn and did some re-thinking and re-coding of the search-function as well as "adjacent" functions. The re-write has resulted in even faster search. With my sample JSON structure, the search-performance is down to 64ms from 800ms. The new approach requires me to re-write the trace-function (does not affect to search performance). The trace-function is used to highlight matches in the XPath Evaluator. I would appreciate if you find time to try out the new update. |
Hi hbi99, Thank you for the hard work, I tried out the new update and yes its even faster than the first attempt now, impressive work. However, the original object is not updated/referenced... Take the previous example, the result should be: but i only get the original object as: The search performance now is impressive though :) Cheers, |
The latest commit in the benchmark branch should fix it...(though I think this code requires more testing). I'll write more Jasmine-tests for this branch before merging it to master-branch. |
Its working great and speedy in my app now. Thank you :) |
@duyhung85 Great :) Thanks |
Create some benchmarks and improve the speed of the search function
The text was updated successfully, but these errors were encountered: