-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating README.md, .npmignore, adding
precise
dev dependency for `…
…benchmark.js`
- Loading branch information
Showing
6 changed files
with
45,133 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,6 @@ | |
.eslintrc | ||
.gitignore | ||
.travis.yml | ||
rollup.config.js | ||
benchmark.js | ||
rollup.config.js | ||
data.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
const path = require("path"), | ||
{haro} = require(path.join(__dirname, "dist", "haro.cjs.js")), | ||
precise = require("precise"), | ||
data = require(path.join(__dirname, "data.json")); | ||
|
||
let indexes; | ||
|
||
function second () { | ||
const timer = precise().start(), | ||
store = haro(null, {id: "test", key: "_id", index: ["name", "eyeColor", "age", "gender", "isActive"]}); | ||
let i, nth; | ||
|
||
store.override(data, "records"); | ||
store.override(indexes, "indexes"); | ||
|
||
i = -1; | ||
nth = 5; | ||
|
||
timer.stop(); | ||
console.log(`time to override data: ${timer.diff() / 1000000} ms`); | ||
console.log("testing time to 'search(regex, index)' on overridden data for a record (first one is cold):"); | ||
|
||
while (++i < nth) { | ||
const timer2 = precise().start(), | ||
record = store.search(/Carly Conway/, "name"); | ||
|
||
timer2.stop(); | ||
console.log(timer2.diff() / 1000000 + "ms"); | ||
|
||
if (!record) { | ||
console.log("Couldn't find record"); | ||
} | ||
} | ||
} | ||
|
||
function first () { | ||
const timer = precise().start(), | ||
store = haro(null, {id: "test", key: "_id", index: ["name", "eyeColor", "age", "gender", "isActive"]}); | ||
let i, nth; | ||
|
||
store.batch(data, "set"); | ||
timer.stop(); | ||
console.log(`time to batch insert data: ${timer.diff() / 1000000} ms`); | ||
console.log(`datastore record count: ${store.size}`); | ||
console.log(`name indexes: ${store.indexes.get("name").size}\n`); | ||
|
||
i = -1; | ||
nth = 5; | ||
|
||
console.log("testing time to 'find()' a record (first one is cold):"); | ||
indexes = store.dump("indexes"); | ||
|
||
while (++i < nth) { | ||
const timer2 = precise().start(), | ||
record = store.find({name: "Muriel Osborne"}); | ||
|
||
timer2.stop(); | ||
console.log(timer2.diff() / 1000000 + "ms"); | ||
|
||
if (!record) { | ||
console.log("Couldn't find record"); | ||
} | ||
} | ||
|
||
console.log(""); | ||
|
||
i = -1; | ||
nth = 5; | ||
|
||
console.log("testing time to 'search(regex, index)' for a record (first one is cold):"); | ||
|
||
while (++i < nth) { | ||
const timer2 = precise().start(), | ||
record = store.search(/Lizzie Clayton/, "name"); | ||
|
||
timer2.stop(); | ||
console.log(timer2.diff() / 1000000 + "ms"); | ||
|
||
if (!record) { | ||
console.log("Couldn't find record"); | ||
} | ||
} | ||
|
||
console.log(""); | ||
second(); | ||
} | ||
|
||
first(); |
Oops, something went wrong.