JS Search vs Lunr JS - Building Index

JavaScript performance comparison

Revision 5 of this test case created by Brian Vaughn

Preparation code

<script type="text/javascript" src="https://rawgit.com/olivernn/lunr.js/master/lunr.js"></script>
<script type="text/javascript" src="https://rawgit.com/bvaughn/js-search/1.2.0/dist/js-search.js"></script>
      
<script>
Benchmark.prototype.setup = function() {
  var books = [];
  var xmlhttp = new XMLHttpRequest();
  xmlhttp.onreadystatechange = function() {
    if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
      var json = JSON.parse(xmlhttp.responseText);
  
      books = json.books;
    }
  }
  xmlhttp.open('GET', 'http://bvaughn.github.io/js-search/books.json', true);
  xmlhttp.send();

};
</script>

Preparation code output

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
Lunr JS: Building index
var lunrJsIndex = new lunr.Index

lunrJsIndex.field('title')
lunrJsIndex.field('author')
lunrJsIndex.ref('isbn')

for (var i = 0, length = books.length; i < length; i++) {
  lunrJsIndex.add(books[i]);
}
pending…
JS Search: Building index (TF-IDF enabled)
var search = new JsSearch.Search('isbn');
search.searchIndex = new JsSearch.TfIdfSearchIndex('isbn');
search.addIndex('title');
search.addIndex('author');
search.addDocuments(books);
pending…
JS Search: Building index (TF-IDF disabled)
var search = new JsSearch.Search('isbn');
search.searchIndex = new JsSearch.UnorderedSearchIndex();
search.addIndex('title');
search.addIndex('author');
search.addDocuments(books);
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL.

0 Comments