-
-
Notifications
You must be signed in to change notification settings - Fork 362
doc(Modbus): add Benchmark result #6753
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's GuideThis PR enhances the Modbus sample by specifying maximum read/write counts and integrating a benchmark project with code and results, and refines the data entity conversion logic by improving attribute handling and adding null assignment support. Sequence diagram for Modbus benchmark executionsequenceDiagram
participant Benchmark
participant ModbusFactory
participant IModbusClient
Benchmark->>ModbusFactory: GetOrCreateTcpMaster() x10
ModbusFactory-->>Benchmark: IModbusClient x10
loop For each client
Benchmark->>IModbusClient: ConnectAsync("127.0.0.1", 502)
Benchmark->>IModbusClient: ReadHoldingRegistersAsync(0x01, 0x00, 100)
end
loop For each client (10)
loop For each task (10)
loop For each operation (10)
Benchmark->>IModbusClient: ReadHoldingRegistersAsync(1, 0, 100)
end
end
end
Sequence diagram for improved DataEntities property assignmentsequenceDiagram
participant "PropertyInfo (p)"
participant "DataPropertyConverterAttribute (attr)"
participant "DataEntity (entity)"
"PropertyInfo (p)"->>"DataPropertyConverterAttribute (attr)": GetCustomAttribute()
alt attr.Type is not null
"PropertyInfo (p)"->>"DataPropertyConverterAttribute (attr)": ConvertTo(data)
"PropertyInfo (p)"->>"DataEntity (entity)": SetValue(entity, value/null)
end
Class diagram for updated Modbus benchmark logicclassDiagram
class ModbusFactory {
+GetOrCreateTcpMaster()
}
class IModbusClient {
+ConnectAsync(ip, port)
+ReadHoldingRegistersAsync(unitId, address, count)
}
class Benchmark {
+LongbowModbus()
}
ModbusFactory --> IModbusClient : creates
Benchmark --> IModbusClient : uses
File-Level Changes
Assessment against linked issues
Possibly linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds Benchmark test results documentation to the Modbus component, demonstrating performance comparisons between LongbowModbus and NModbus libraries.
- Adds documentation for Modbus operation limits (max read/write quantities for different types)
- Includes comprehensive benchmark test code showing concurrent socket connections and task execution
- Provides performance comparison results between LongbowModbus and NModbus implementations
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/BootstrapBlazor.Server/Components/Samples/Sockets/DataEntities.razor | Updates property converter code example to include null handling logic |
| src/BootstrapBlazor.Server/Components/Samples/Modbus/ModbusFactories.razor | Adds benchmark documentation with performance test code and results comparison |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/BootstrapBlazor.Server/Components/Samples/Modbus/ModbusFactories.razor
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes and they look great!
Prompt for AI Agents
Please address the comments from this code review:
## Individual Comments
### Comment 1
<location> `src/BootstrapBlazor.Server/Components/Samples/Modbus/ModbusFactories.razor:63-65` </location>
<code_context>
- <li>离散输入 (Discrete Inputs) <code>ReadInputsAsync</code></li>
- <li>输入寄存器 (Input Registers) <code>ReadInputRegistersAsync</code></li>
- <li>保持寄存器 (Holding Registers) <code>ReadHoldingRegistersAsync</code> <code>WriteRegisterAsync</code> <code>WriteMultipleRegistersAsync</code></li>
+ <li>线圈 (Coils) <code>ReadCoilsAsync</code> <code>WriteCoilAsync</code> <code>WriteMultipleCoilsAsync</code> 最大读取数量 <code>2000</code> 最大写入数量 <code>1968</code></li>
+ <li>离散输入 (Discrete Inputs) <code>ReadInputsAsync</code> 最大读取数量 <code>2000</code></li>
+ <li>输入寄存器 (Input Registers) <code>ReadInputRegistersAsync</code> 最大读取数量 <code>125</code></li>
+ <li>保持寄存器 (Holding Registers) <code>ReadHoldingRegistersAsync</code> <code>WriteRegisterAsync</code> <code>WriteMultipleRegistersAsync</code> 最大读取数量 <code>125</code> 最大写入数量 <code>123</code></li>
</ul>
+
</code_context>
<issue_to_address>
**suggestion:** Clarify source of Modbus protocol limits for maintainability.
Reference the Modbus specification or add a brief comment explaining the origin of these hardcoded limits to improve maintainability.
```suggestion
<!--
Modbus 协议的最大读取/写入数量限制参考自 Modbus Application Protocol Specification V1.1b3:
- 线圈 (Coils) 最大读取数量: 2000, 最大写入数量: 1968
- 离散输入 (Discrete Inputs) 最大读取数量: 2000
- 输入寄存器 (Input Registers) 最大读取数量: 125
- 保持寄存器 (Holding Registers) 最大读取数量: 125, 最大写入数量: 123
详见: https://modbus.org/docs/Modbus_Application_Protocol_V1_1b3.pdf
-->
<p>对应 <code>IModbusClient</code> 实例方法如下</p>
<ul class="ul-demo">
```
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
src/BootstrapBlazor.Server/Components/Samples/Modbus/ModbusFactories.razor
Show resolved
Hide resolved
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #6753 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 739 739
Lines 31713 31713
Branches 4462 4462
=========================================
Hits 31713 31713
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Link issues
fixes #6752
Summary By Copilot
Regression?
Risk
Verification
Packaging changes reviewed?
☑️ Self Check before Merge
Summary by Sourcery
Document Modbus client limits and include a performance benchmark comparison, and enhance data conversion logic to support nullable properties.
Bug Fixes:
Enhancements:
Documentation:
Tests: