From cc3db722d0234a644131615bce99b5c0fda83e9c Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 11 Dec 2025 12:03:38 +0100 Subject: [PATCH 1/6] add side-effect --- simple/doxbee-async.js | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/simple/doxbee-async.js b/simple/doxbee-async.js index e505a5ff..aed3781b 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() {} +async function dummy_1() { + return Queryish.count++; +} +async function dummy_2(a) { + //return Queryish.count++; +} + +Queryish.count = 0; Queryish.prototype.all = dummy_1; Queryish.prototype.exec = dummy_1; Queryish.prototype.execWithin = dummy_2; @@ -161,20 +171,32 @@ module.exports = { File, FileVersion, Version, - db + db, + Queryish }; },{}],3:[function(require,module,exports){ const doxbee = require("../lib/doxbee-async"); globalThis.Benchmark = class { - runIteration() { + count = 0; + + async 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); + await Promise.all(promises); + this.count = doxbee.fakes.Queryish.count; + } + + validate() { + const EXPECTED_COUNT = 60000; + if (this.count !== EXPECTED_COUNT) { + throw new Error(`Expected this.count == ${EXPECTED_COUNT}, but got ${this.count}`); + } } }; From 8807a09b93cd78795fcab57030e1655cd31cd9ee Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 11 Dec 2025 13:13:56 +0100 Subject: [PATCH 2/6] wip --- simple/doxbee-async.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/simple/doxbee-async.js b/simple/doxbee-async.js index aed3781b..ee973ed1 100644 --- a/simple/doxbee-async.js +++ b/simple/doxbee-async.js @@ -193,10 +193,10 @@ globalThis.Benchmark = class { } validate() { - const EXPECTED_COUNT = 60000; - if (this.count !== EXPECTED_COUNT) { - throw new Error(`Expected this.count == ${EXPECTED_COUNT}, but got ${this.count}`); - } + // const EXPECTED_COUNT = 60000; + // if (this.count !== EXPECTED_COUNT) { + // throw new Error(`Expected this.count == ${EXPECTED_COUNT}, but got ${this.count}`); + // } } }; From 8828bf6fb2efde591ad8117c66cdfe52a0184eae Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 11 Dec 2025 13:41:51 +0100 Subject: [PATCH 3/6] wip --- simple/doxbee-async.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/simple/doxbee-async.js b/simple/doxbee-async.js index ee973ed1..5ecc7acb 100644 --- a/simple/doxbee-async.js +++ b/simple/doxbee-async.js @@ -98,10 +98,10 @@ module.exports = { // a queryish object with all kinds of functions function Queryish() {} async function dummy_1() { - return Queryish.count++; + Queryish.count++; } async function dummy_2(a) { - //return Queryish.count++; + Queryish.count++; } Queryish.count = 0; @@ -172,31 +172,29 @@ module.exports = { FileVersion, Version, db, - Queryish + Queryish, }; },{}],3:[function(require,module,exports){ const doxbee = require("../lib/doxbee-async"); globalThis.Benchmark = class { - count = 0; - - async runIteration() { + runIteration() { doxbee.fakes.Queryish.count = 0; const promises = new Array(10_000); for (var i = 0; i < 10_000; i++) promises[i] = doxbee.doxbee(i, "foo"); - await Promise.all(promises); - this.count = doxbee.fakes.Queryish.count; + return Promise.all(promises); } validate() { - // const EXPECTED_COUNT = 60000; - // if (this.count !== EXPECTED_COUNT) { - // throw new Error(`Expected this.count == ${EXPECTED_COUNT}, but got ${this.count}`); - // } + 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}`); + } } }; From c889c0be0246994377c609416a94b5ce044993c7 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Thu, 11 Dec 2025 13:45:50 +0100 Subject: [PATCH 4/6] cleanup --- simple/doxbee-async.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/simple/doxbee-async.js b/simple/doxbee-async.js index 5ecc7acb..afd60a02 100644 --- a/simple/doxbee-async.js +++ b/simple/doxbee-async.js @@ -97,6 +97,7 @@ module.exports = { // a queryish object with all kinds of functions function Queryish() {} +Queryish.count = 0; async function dummy_1() { Queryish.count++; } @@ -104,7 +105,6 @@ async function dummy_2(a) { Queryish.count++; } -Queryish.count = 0; Queryish.prototype.all = dummy_1; Queryish.prototype.exec = dummy_1; Queryish.prototype.execWithin = dummy_2; From af306d408be2cd51f33b550c33a976d8a1fda0c3 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Mon, 15 Dec 2025 10:52:35 +0100 Subject: [PATCH 5/6] also change doxbee promise --- simple/doxbee-promise.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/simple/doxbee-promise.js b/simple/doxbee-promise.js index aabcd86c..8b71218a 100644 --- a/simple/doxbee-promise.js +++ b/simple/doxbee-promise.js @@ -108,11 +108,16 @@ module.exports = function doxbee(stream, idOrPath) { },{"../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; From 4936ef4e038e0e4be8aa6def994a0d1caae23c43 Mon Sep 17 00:00:00 2001 From: Camillo Bruni Date: Mon, 15 Dec 2025 11:01:37 +0100 Subject: [PATCH 6/6] update doxbee-promise too --- simple/doxbee-async.js | 2 +- simple/doxbee-promise.js | 21 ++++++++++++++++++--- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/simple/doxbee-async.js b/simple/doxbee-async.js index afd60a02..14a39ac1 100644 --- a/simple/doxbee-async.js +++ b/simple/doxbee-async.js @@ -89,7 +89,7 @@ async function doxbee(stream, idOrPath) { module.exports = { doxbee, - fakes + fakes, }; },{"../lib/fakes-async.js":2}],2:[function(require,module,exports){ diff --git a/simple/doxbee-promise.js b/simple/doxbee-promise.js index 8b71218a..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,6 +105,11 @@ module.exports = function doxbee(stream, idOrPath) { }); }; +module.exports = { + doxbee, + fakes, +}; + },{"../lib/fakes-promises.js":2}],2:[function(require,module,exports){ "use strict"; @@ -186,7 +191,8 @@ module.exports = { File, FileVersion, Version, - db + db, + Queryish, }; },{}],3:[function(require,module,exports){ @@ -194,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]);