Skip to content
Open
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
32 changes: 26 additions & 6 deletions simple/doxbee-async.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

const fakes = require("../lib/fakes-async.js");

module.exports = async function doxbee(stream, idOrPath) {
async function doxbee(stream, idOrPath) {
const blob = fakes.blobManager.create(fakes.account);
const tx = fakes.db.begin();

Expand Down Expand Up @@ -87,14 +87,24 @@ module.exports = async function doxbee(stream, idOrPath) {
}
};

module.exports = {
doxbee,
fakes,
};

},{"../lib/fakes-async.js":2}],2:[function(require,module,exports){
"use strict";

async function dummy_1() { }
async function dummy_2(a) { }

// a queryish object with all kinds of functions
function Queryish() {}
Queryish.count = 0;
async function dummy_1() {
Queryish.count++;
}
async function dummy_2(a) {
Queryish.count++;
}

Queryish.prototype.all = dummy_1;
Queryish.prototype.exec = dummy_1;
Queryish.prototype.execWithin = dummy_2;
Expand Down Expand Up @@ -161,21 +171,31 @@ module.exports = {
File,
FileVersion,
Version,
db
db,
Queryish,
};

},{}],3:[function(require,module,exports){
const doxbee = require("../lib/doxbee-async");

globalThis.Benchmark = class {
runIteration() {
doxbee.fakes.Queryish.count = 0;
const promises = new Array(10_000);

for (var i = 0; i < 10_000; i++)
promises[i] = doxbee(i, "foo");
promises[i] = doxbee.doxbee(i, "foo");

return Promise.all(promises);
}

validate() {
const EXPECTED_COUNT = 70000;
const count = doxbee.fakes.Queryish.count;
if (count !== EXPECTED_COUNT) {
throw new Error(`Expected this.count == ${EXPECTED_COUNT}, but got ${count}`);
}
}
};

},{"../lib/doxbee-async":1}]},{},[3]);
32 changes: 26 additions & 6 deletions simple/doxbee-promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@

const fakes = require("../lib/fakes-promises.js");

module.exports = function doxbee(stream, idOrPath) {
function doxbee(stream, idOrPath) {
const blob = fakes.blobManager.create(fakes.account);
const tx = fakes.db.begin();
let version, blobId, fileId, file;
Expand Down Expand Up @@ -105,14 +105,24 @@ module.exports = function doxbee(stream, idOrPath) {
});
};

module.exports = {
doxbee,
fakes,
};

},{"../lib/fakes-promises.js":2}],2:[function(require,module,exports){
"use strict";

function dummy_1() { return Promise.resolve(undefined); }
function dummy_2(a) { return Promise.resolve(undefined); }

// a queryish object with all kinds of functions
function Queryish() {}
Queryish.count = 0;
async function dummy_1() {
Queryish.count++;
}
async function dummy_2(a) {
Queryish.count++;
}

Queryish.prototype.all = dummy_1;
Queryish.prototype.exec = dummy_1;
Queryish.prototype.execWithin = dummy_2;
Expand Down Expand Up @@ -181,21 +191,31 @@ module.exports = {
File,
FileVersion,
Version,
db
db,
Queryish,
};

},{}],3:[function(require,module,exports){
const doxbee = require("../lib/doxbee-promises");

globalThis.Benchmark = class {
runIteration() {
doxbee.fakes.Queryish.count = 0;
const promises = new Array(10_000);

for (var i = 0; i < 10_000; i++)
promises[i] = doxbee(i, "foo");
promises[i] = doxbee.doxbee(i, "foo");

return Promise.all(promises);
}

validate() {
const EXPECTED_COUNT = 70000;
const count = doxbee.fakes.Queryish.count;
if (count !== EXPECTED_COUNT) {
throw new Error(`Expected this.count == ${EXPECTED_COUNT}, but got ${count}`);
}
}
};

},{"../lib/doxbee-promises":1}]},{},[3]);
Loading