-
-
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.
Initial refactoring to storing
ArrayBuffer
instances instead of `Ob…
…jects`
- Loading branch information
Showing
9 changed files
with
158 additions
and
12 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,5 @@ | |
.eslintrc | ||
.gitignore | ||
.travis.yml | ||
rollup.config.js | ||
data.json | ||
rollup.config.js |
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,94 @@ | ||
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"]}), | ||
deferreds = []; | ||
|
||
deferreds.push(store.override(data, "records")); | ||
deferreds.push(store.override(indexes, "indexes")); | ||
|
||
Promise.all(deferreds).then(function () { | ||
let 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) { | ||
(function () { | ||
const timer2 = precise().start(); | ||
const 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"]}); | ||
|
||
store.batch(data, "set").then(function () { | ||
timer.stop(); | ||
console.log("time to batch insert data: " + (timer.diff() / 1000000) + "ms"); | ||
console.log("datastore record count: " + store.total); | ||
console.log("name indexes: " + store.indexes.get("name").size + "\n"); | ||
}).then(function () { | ||
let i = -1, | ||
nth = 5; | ||
|
||
console.log("testing time to 'find()' a record (first one is cold):"); | ||
indexes = store.dump("indexes"); | ||
|
||
while (++i < nth) { | ||
(function () { | ||
const timer2 = precise().start(); | ||
const record = store.find({name: "Muriel Osborne"}); | ||
timer2.stop(); | ||
console.log((timer2.diff() / 1000000) + "ms"); | ||
|
||
if (!record) { | ||
console.log("Couldn't find record"); | ||
} | ||
}()); | ||
} | ||
|
||
console.log(""); | ||
}).then(function () { | ||
let i = -1, | ||
nth = 5; | ||
|
||
console.log("testing time to 'search(regex, index)' for a record (first one is cold):"); | ||
|
||
while (++i < nth) { | ||
(function () { | ||
const timer2 = precise().start(); | ||
const 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(); |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.