Skip to content
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

Binary storage #71

Merged
merged 7 commits into from
Dec 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@
.eslintrc
.gitignore
.travis.yml
rollup.config.js
data.json
rollup.config.js
94 changes: 94 additions & 0 deletions benchmark.js
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();
Loading