diff --git a/simple/doxbee-async.js b/simple/doxbee-async.js index e505a5ff..14a39ac1 100644 --- a/simple/doxbee-async.js +++ b/simple/doxbee-async.js @@ -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(); @@ -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; @@ -161,7 +171,8 @@ module.exports = { File, FileVersion, Version, - db + db, + Queryish, }; },{}],3:[function(require,module,exports){ @@ -169,13 +180,22 @@ 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]); diff --git a/simple/doxbee-promise.js b/simple/doxbee-promise.js index aabcd86c..bf3cac2d 100644 --- a/simple/doxbee-promise.js +++ b/simple/doxbee-promise.js @@ -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; @@ -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; @@ -181,7 +191,8 @@ module.exports = { File, FileVersion, Version, - db + db, + Queryish, }; },{}],3:[function(require,module,exports){ @@ -189,13 +200,22 @@ 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]);