diff --git a/examples/benchmark.js b/examples/benchmark.js index ef44627..5effa36 100644 --- a/examples/benchmark.js +++ b/examples/benchmark.js @@ -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); }); diff --git a/examples/reader.js b/examples/reader.js index 8853c09..5f4c190 100644 --- a/examples/reader.js +++ b/examples/reader.js @@ -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("---------------------------------------------------")