# BenchmarkOut

BenchmarkOut 节点会监听第一条传入消息，然后按照指定的帧率（FPS）重复发送该消息的副本。 当你需要模拟来自输入的持续数据流，以便测试管线的性能时，这个节点非常有用。

## 如何放置

#### Python

```python
import depthai as dai

pipeline = dai.Pipeline()
benchmarkOut = pipeline.create(dai.node.BenchmarkOut)

# 选择节点在主机上运行还是在设备上运行
benchmarkOut.setRunOnHost(False)
# 设置期望的输出帧率（FPS）
benchmarkOut.setFps(30)

# 初始化：发送一条输入消息（例如，一个 ImgFrame）
inputQueue = benchmarkOut.input.createInputQueue()
# 根据需要创建并配置初始帧
initialFrame = dai.ImgFrame()
inputQueue.send(initialFrame)
```

#### C++

```cpp
#include "depthai/depthai.hpp"

dai::Pipeline pipeline;
auto benchmarkOut = pipeline.create<dai::node::BenchmarkOut>();

// 选择在主机上运行还是在设备上运行，并设置输出帧率
benchmarkOut->setRunOnHost(false);
benchmarkOut->setFps(30);

// 初始化节点：发送一帧数据
auto inputQueue = benchmarkOut->input.createInputQueue();
dai::ImgFrame initialFrame;
// 根据需要初始化 initialFrame ...
inputQueue->send(initialFrame);
```

## 输入与输出

## 使用

#### Python

```python
pipeline = dai.Pipeline()
benchmarkOut = pipeline.create(dai.node.BenchmarkOut)
benchmarkOut.setRunOnHost(True)
benchmarkOut.setFps(30)

# 发送一帧数据来初始化输出流。
inputQueue = benchmarkOut.input.createInputQueue()
initialFrame = dai.ImgFrame()
# (根据需要初始化 initialFrame)
inputQueue.send(initialFrame)

# 示例：将 BenchmarkOut 的输出连接到 BenchmarkIn 节点以进行性能测量。
benchmarkIn = pipeline.create(dai.node.BenchmarkIn)
benchmarkOut.out.link(benchmarkIn.input)

outputQueue = benchmarkIn.report.createOutputQueue()
while pipeline.isRunning():
    benchmarkReport = outputQueue.get()
    print(f"FPS 为 {benchmarkReport.fps}")
```

#### C++

```cpp
#include "depthai/depthai.hpp"

dai::Pipeline pipeline;
auto benchmarkOut = pipeline.create<dai::node::BenchmarkOut>();
benchmarkOut->setRunOnHost(true);
benchmarkOut->setFps(30);

// 发送一帧数据来初始化流
auto inputQueue = benchmarkOut->input.createInputQueue();
dai::ImgFrame initialFrame;
// 根据需要初始化 initialFrame ...
inputQueue->send(initialFrame);

// 示例：将 BenchmarkOut 的输出连接到 BenchmarkIn 节点以进行性能测量。
auto benchmarkIn = pipeline.create<dai::node::BenchmarkIn>();
benchmarkOut->out.link(benchmarkIn->input);

auto outputQueue = benchmarkIn->report.createOutputQueue();
while(pipeline.isRunning()) {
    auto benchmarkReport = outputQueue->get<dai::BenchmarkReport>();
    std::cout << "FPS 为 " << benchmarkReport.fps << std::endl;
}
```

## 功能示例

 * [Benchmark NN](https://docs.luxonis.com/software-v3/depthai/examples/benchmark/benchmark_nn.md)
 * [Benchmark Simple](https://docs.luxonis.com/software-v3/depthai/examples/benchmark/benchmark_simple.md)

## 参考

### dai::node::BenchmarkOut

Kind: class

#### Output out

Kind: variable

Send messages out as fast as possible

#### Input input

Kind: variable

Message that will be sent repeatedly

#### void setNumMessagesToSend(int num)

Kind: function

Sets number of messages to send, by default send messages indefinitely parameters: num: number of messages to send

#### void setFps(float fps)

Kind: function

Set FPS at which the node is sending out messages. 0 means as fast as possible

#### void setRunOnHost(bool runOnHost)

Kind: function

Specify whether to run on host or device By default, the node will run on device.

#### bool runOnHost()

Kind: function

Check if the node is set to run on host

#### void run()

Kind: function

#### DeviceNodeCRTP()

Kind: function

#### DeviceNodeCRTP(const std::shared_ptr< Device > & device)

Kind: function

#### DeviceNodeCRTP(std::unique_ptr< Properties > props)

Kind: function

#### DeviceNodeCRTP(std::unique_ptr< Properties > props, bool confMode)

Kind: function

#### DeviceNodeCRTP(const std::shared_ptr< Device > & device, std::unique_ptr< Properties > props, bool confMode)

Kind: function

### 需要帮助？

请前往 [OAKChina 官网](https://www.oakchina.cn/) 获取技术支持或解答您的任何疑问。
