This commit is contained in:
haad
2016-02-26 13:45:57 +01:00
parent 5f639c87fe
commit 7f34829645
6 changed files with 21 additions and 50 deletions

View File

@@ -12,37 +12,32 @@ const port = 3333;
const username = process.argv[3] ? process.argv[3] : 'LambOfGod';
const password = '';
let running = false;
let run = (async(() => {
if(!running) {
try {
running = true;
const orbit = OrbitClient.connect(host, port, username, password);
const channel = process.argv[2] ? process.argv[2] : 'testing123';
const db = orbit.channel(channel);
try {
const orbit = OrbitClient.connect(host, port, username, password);
const channel = process.argv[2] ? process.argv[2] : 'testing123';
const db = orbit.channel(channel);
let count = 1;
let count = 1;
setInterval(async(() => {
const key = process.argv[4] ? process.argv[4] : 'greeting';
let timer = new Timer(true);
let v = db.get(key);
setInterval(async(() => {
const key = process.argv[4] ? process.argv[4] : 'greeting';
let timer = new Timer(true);
let v = db.get(key);
console.log("---------------------------------------------------")
console.log("Key | Value")
console.log("---------------------------------------------------")
console.log(`${key} | ${v}`);
console.log("---------------------------------------------------")
console.log(`Query #${count} took ${timer.stop(true)} ms\n`);
console.log("---------------------------------------------------")
console.log("Key | Value")
console.log("---------------------------------------------------")
console.log(`${key} | ${v}`);
console.log("---------------------------------------------------")
console.log(`Query #${count} took ${timer.stop(true)} ms\n`);
count ++;
running = false;
}), 1000);
} catch(e) {
console.error("error:", e);
console.error(e.stack);
process.exit(1);
}
count ++;
}), 1000);
} catch(e) {
console.error("error:", e);
console.error(e.stack);
process.exit(1);
}
}))();

View File

@@ -33,14 +33,12 @@ let run = (async(() => {
console.log(`Query #${count} took ${timer.stop(true)} ms\n`);
let timer2 = new Timer(true);
// const c = channel.iterator({ limit: -1 }).collect().length;
let items = channel.iterator({ limit: 10 }).collect();
console.log("---------------------------------------------------")
console.log("Key | Value")
console.log("---------------------------------------------------")
console.log(items.map((e) => `${e.payload.key} | ${e.payload.value}`).join("\n"));
console.log("---------------------------------------------------")
// console.log(`Found ${items.length} items from ${c}\n`);
console.log(`Query 2 #${count} took ${timer2.stop(true)} ms\n`);
running = false;