# BenchmarkOut

The BenchmarkOut node listens for the first incoming message and then repeatedly sends out copies of that message at a specified
frame rate (FPS). This is useful when you need to simulate a continuous stream from an input, which allows you to test the
performance of your pipeline.

## How to place it

#### Python

```python
import depthai as dai

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

# Choose whether the node runs on the host or on the device
benchmarkOut.setRunOnHost(False)
# Set the desired output frame rate (FPS)
benchmarkOut.setFps(30)

# To initialize, send a single input message (e.g., an ImgFrame)
inputQueue = benchmarkOut.input.createInputQueue()
# Create and configure your initial frame as needed
initialFrame = dai.ImgFrame()
inputQueue.send(initialFrame)
```

#### C++

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

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

// Choose whether to run on host or device and set the output FPS
benchmarkOut->setRunOnHost(false);
benchmarkOut->setFps(30);

// To initialize the node, send a single frame
auto inputQueue = benchmarkOut->input.createInputQueue();
dai::ImgFrame initialFrame;
// Initialize initialFrame as needed...
inputQueue->send(initialFrame);
```

## Inputs and Outputs

## Usage

#### Python

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

# Send a single frame to initialize the output stream.
inputQueue = benchmarkOut.input.createInputQueue()
initialFrame = dai.ImgFrame()
# (Initialize initialFrame as needed)
inputQueue.send(initialFrame)

# Example: Link BenchmarkOut's output to a BenchmarkIn node for performance measurement.
benchmarkIn = pipeline.create(dai.node.BenchmarkIn)
benchmarkOut.out.link(benchmarkIn.input)

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

#### C++

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

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

// Send a single frame to initialize the stream
auto inputQueue = benchmarkOut->input.createInputQueue();
dai::ImgFrame initialFrame;
// Initialize initialFrame as needed...
inputQueue->send(initialFrame);

// Example: Link BenchmarkOut's output to a BenchmarkIn node for measuring performance.
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 is " << benchmarkReport.fps << std::endl;
}
```

## Examples of functionality

 * [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)

## Reference

### 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

### Need assistance?

Head over to [Discussion Forum](https://discuss.luxonis.com/) for technical support or any other questions you might have.
