Skip to content

Commit a4cb123

Browse files
authored
Avoid new Date and improve filename extraction in doxbee benchmarks (#231)
Both benchmarks seem to spend quite a bit of time in new Date() and extracting file names from the idOrPath variable. The date is never really accessed which makes this a bit a weird pattern to have such a high weight. - Remove new Date() for version - Use lastIndexOf in one of the two benchmarks to get a bit diversity
1 parent c6f6855 commit a4cb123

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

simple/doxbee-async.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ module.exports = async function doxbee(stream, idOrPath) {
4949
const previousId = file ? file.version : null;
5050
const version = {
5151
userAccountId: fakes.userAccount.id,
52-
date: new Date(),
5352
blobId: blobId,
5453
creatorId: fakes.userAccount.id,
5554
previousId: previousId

simple/doxbee-promise.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ module.exports = function doxbee(stream, idOrPath) {
5555
const previousId = file ? file.version : null;
5656
version = {
5757
userAccountId: fakes.userAccount.id,
58-
date: new Date(),
5958
blobId: blobId,
6059
creatorId: fakes.userAccount.id,
6160
previousId: previousId
@@ -65,8 +64,8 @@ module.exports = function doxbee(stream, idOrPath) {
6564
})
6665
.then(_ => {
6766
if (!file) {
68-
const splitPath = idOrPath.split("/");
69-
const fileName = splitPath[splitPath.length - 1];
67+
const splitPath = idOrPath.lastIndexOf("/") + 1;
68+
const fileName = idOrPath.substring(splitPath);
7069
const newId = fakes.uuid.v1();
7170
return fakes.self
7271
.createQuery(idOrPath, {

0 commit comments

Comments
 (0)