Skip to content

Commit

Permalink
Added timing
Browse files Browse the repository at this point in the history
  • Loading branch information
allouis committed Aug 6, 2024
1 parent 9909058 commit ff0f0a5
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/dispatchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,11 +254,16 @@ export async function followersDispatcher(
let items: Actor[] = [];
const fullResults = await ctx.data.db.get<any[]>(['followers', 'expanded']);
if (fullResults) {
console.time(`Creating Objects`);
items = (await Promise.all(
fullResults.map((result): Promise<APObject> => {
return APObject.fromJsonLd(result);
fullResults.map((result, i): Promise<APObject> => {
console.time(`Creating Object ${i}`)
const res = APObject.fromJsonLd(result);
console.timeEnd(`Creating Object ${i}`)
return res;
})
)).filter((item): item is Actor => isActor(item));
console.timeEnd(`Creating Objects`);
} else {
const results = (await ctx.data.db.get<string[]>(['followers'])) || [];
items = (await Promise.all(results.map((result) => lookupActor(ctx, result))))
Expand Down

0 comments on commit ff0f0a5

Please sign in to comment.