Fix examples

This commit is contained in:
haad 2016-04-12 18:14:59 +02:00
parent b3c2f5bbc3
commit 3da2dbcad6
2 changed files with 11 additions and 13 deletions

View File

@ -11,15 +11,15 @@ var Timer = require('./Timer');
const host = process.argv[2] ? process.argv[2] : 'localhost'
const port = 3333;
var username = process.argv[3] ? process.argv[3] : 'testrunner';
var password = '';
const username = process.argv[3] ? process.argv[3] : 'testrunner';
const password = '';
const channelName = process.argv[4] ? process.argv[4] : 'c1';
let run = (async(() => {
try {
// Connect
var orbit = OrbitClient.connect(host, port, username, password);
const channelName = process.argv[4] ? process.argv[4] : 'c1';
const orbit = await(OrbitClient.connect(host, port, username, password));
const db = orbit.channel(channelName);
// Metrics
@ -47,15 +47,13 @@ let run = (async(() => {
}, 1000);
const query = async(() => {
// let timer = new Timer();
// while(true) {
// let timer = new Timer();
// timer.start();
await(db.add(username + totalQueries));
// console.log(`${timer.stop(true)} ms`);
totalQueries ++;
lastTenSeconds ++;
queriesPerSecond ++;
// }
process.nextTick(query);
});

View File

@ -14,13 +14,13 @@ const port = 3333;
const username = process.argv[3] ? process.argv[3] : 'LambOfGod';
const password = '';
const channelName = process.argv[4] ? process.argv[4] : 'test';
const prefix = process.argv[5] ? process.argv[5] : 'Hello';
let run = (async(() => {
try {
var orbit = OrbitClient.connect(host, port, username, password);
const channelName = process.argv[4] ? process.argv[4] : 'test';
const channel = orbit.channel(channelName);
const orbit = await(OrbitClient.connect(host, port, username, password));
const db = orbit.channel(channelName);
let count = 1;
let running = false;
@ -30,11 +30,11 @@ let run = (async(() => {
running = true;
let timer = new Timer(true);
channel.add(prefix + count);
await(db.add(prefix + count));
console.log(`Query #${count} took ${timer.stop(true)} ms\n`);
let timer2 = new Timer(true);
let items = channel.iterator({ limit: 20 }).collect();
let items = db.iterator({ limit: 20 }).collect();
console.log("---------------------------------------------------")
console.log("Key | Value")
console.log("---------------------------------------------------")