beltrachi / js-mst Goto Github PK
View Code? Open in Web Editor NEWJavascript m-ary search tree
Javascript m-ary search tree
The intention of this code is to proove or test the speed/performance of search trees. In this case, the keys are strings. My intention is to use it in an autocomplete input field but not asking to the server every time. There have been 2 different aproaches: * BST: binary search tree Has demonstrated a low performance, not so much in retrieve as in insertion. You can pass the tests of BST if you want to compare. In a first implementation of BST, we detected that the creation of the nodes as prototype Objects was being expensive, so the nodes were changed to hashes "{}". This reduced the cost of creating nodes to a half. * MST: m-ary search tree The reason to try that was to reduce the navigation cost. When we are looking for a character in the position p, we must navigate through the neighbours till find the node of that char. In the mst, each node has a hash that points to the node of that char. This implementation is suposed to be faster as a hash hit is implemented in machine code in the browser, so should be faster than a script code. The results have shown that mst is better. Inserting 80k words in the bst costs 7 seconds. Inserting 80k words in the mst costs 3 seconds. This tests were taken in a FF 3.0.5 (Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.5) Gecko/2008121621 Ubuntu/8.04 (hardy) Firefox/3.0.5) The computer has a Intel Core 2 Duo T5550 The tests on Internet Explorer 6 were done in a virtualized installation on the same machine as FF3. Some code adaptions were made. The results were really slow. Possibly afected by the virtualization. For instance: Adding 8k words (not 80k) in the mst cost 48 seconds. See that its a tenth of the size of the test on FF and the results are really worse. Pending a test on a non virtualized environment. === Giving a chance to Google Closure Compiler Recently Google has released a javascript suite which includes a javascript compiler which reduces the code and rewrites the code reducing the size and doing some code optimizations. URL: http://code.google.com/closure/ Applying the compiler on the MST source needed some rewritting but it finally passed the tests. The results have been disapointing as has not been any important performance improvement even aplying the advanced optimizations. Probably the code cannot be optimized any more and the time spent is what it needs to do the work expected.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.