Skip to content

Commit

Permalink
perf: collection was not done in parallel
Browse files Browse the repository at this point in the history
  • Loading branch information
Akryum committed May 30, 2022
1 parent 42726df commit 4a0c22a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
4 changes: 1 addition & 3 deletions packages/histoire/src/node/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,7 @@ export async function build (ctx: Context) {
server,
throws: true,
}, ctx)
for (const storyFile of ctx.storyFiles) {
await executeStoryFile(storyFile)
}
await Promise.all(ctx.storyFiles.map(storyFile => executeStoryFile(storyFile)))
await destroyCollectStories()

const storyCount = ctx.storyFiles.reduce((sum, file) => sum + (file.story?.variants.length ? 1 : 0), 0)
Expand Down
9 changes: 3 additions & 6 deletions packages/histoire/src/node/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,15 +110,12 @@ export async function createServer (ctx: Context, port: number) {
await executeStoryFile(changedFile)

// Queued updates
for (const storyFile of queuedFiles) {
await executeStoryFile(storyFile)
}
await Promise.all(queuedFiles.map(storyFile => executeStoryFile(storyFile)))
} else {
// Full update
for (const storyFile of ctx.storyFiles) {
await executeStoryFile(storyFile)
}
await Promise.all(ctx.storyFiles.map(storyFile => executeStoryFile(storyFile)))
didAllStoriesYet = true
server.ws.send('histoire:all-stories-loaded', {})
}
console.log('Collect stories end', Date.now() - time, 'ms')

Expand Down

0 comments on commit 4a0c22a

Please sign in to comment.