translation/translated/documents/course/04-workflows/17-testing-parallel-perform...

41 lines
993 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 测试并行工作流
让我们测试您的并行工作流。
## 注册新工作流
更新您的Mastra配置以包含您的新工作流
```typescript
// In src/mastra/index.ts
import {
contentWorkflow,
aiContentWorkflow,
parallelAnalysisWorkflow,
} from "./workflows/content-workflow";
export const mastra = new Mastra({
workflows: {
contentWorkflow,
aiContentWorkflow,
parallelAnalysisWorkflow, // Add the parallel workflow
},
// ... rest of configuration
});
```
## 测试并行工作流
您现在可以在操练场中测试此新工作流。您将注意到它并行处理三个分析步骤,从而加快执行时间。
## 何时使用并行执行
在以下情况下使用并行执行:
- 步骤不依赖彼此的输出
- 步骤涉及I/O操作API调用、数据库查询
- 您想要最大化性能
- 步骤处理相同的输入数据
将您的并行工作流注册到Mastra以在操练场中使用它接下来您将了解条件分支。