@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
|
||||
<GVL Name="GVL_Perf" Id="{00000000-0000-0000-0000-000000000201}">
|
||||
<Declaration><![CDATA[// PR 2.1 Sum-read perf fixture. 1000 DINTs read in one ADS sum-read by
|
||||
// TwinCATSumCommandPerfTests; FB_PerfChurn rotates a few values each cycle so
|
||||
// the wire isn't reading static data the runtime can short-circuit.
|
||||
//
|
||||
// Required by the perf-tier integration test
|
||||
// Driver_sum_read_1000_tags_beats_loop_baseline_by_5x. See
|
||||
// TwinCatProject/README.md §Performance scenarios.
|
||||
VAR_GLOBAL
|
||||
aTags : ARRAY[1..1000] OF DINT;
|
||||
fbPerfChurn : FB_PerfChurn;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
</GVL>
|
||||
</TcPlcObject>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<TcPlcObject Version="1.1.0.1" ProductVersion="3.1.4024.0">
|
||||
<POU Name="FB_PerfChurn" Id="{00000000-0000-0000-0000-000000000202}" SpecialFunc="None">
|
||||
<Declaration><![CDATA[// Rotating writer for GVL_Perf.aTags so the perf integration test isn't
|
||||
// reading completely static data — keeps the runtime's symbol caches honest.
|
||||
// Increments each tag's value at MAIN-task cadence; touches all 1000 entries
|
||||
// over the 1000 cycles spanning ~10s at the default 10ms PlcTask period.
|
||||
FUNCTION_BLOCK FB_PerfChurn
|
||||
VAR
|
||||
nIndex : INT := 1;
|
||||
END_VAR
|
||||
]]></Declaration>
|
||||
<Implementation>
|
||||
<ST><![CDATA[GVL_Perf.aTags[nIndex] := GVL_Perf.aTags[nIndex] + 1;
|
||||
nIndex := nIndex + 1;
|
||||
IF nIndex > 1000 THEN
|
||||
nIndex := 1;
|
||||
END_IF
|
||||
]]></ST>
|
||||
</Implementation>
|
||||
</POU>
|
||||
</TcPlcObject>
|
||||
@@ -71,6 +71,70 @@ GVL_Fixture.nCounter := GVL_Fixture.nCounter + 1;
|
||||
- `PlcTask` — cyclic, 10 ms interval, priority 20
|
||||
- Assigned to `MAIN`
|
||||
|
||||
## Performance scenarios
|
||||
|
||||
PR 2.1 (ADS Sum-read / Sum-write) ships an opt-in perf-tier integration test
|
||||
(`TwinCATSumCommandPerfTests.Driver_sum_read_1000_tags_beats_loop_baseline_by_5x`)
|
||||
that reads 1000 DINTs in one shot and asserts the bulk path beats the per-tag
|
||||
loop by ≥ 5×. The fixture state required by that test is:
|
||||
|
||||
### Global Variable List: `GVL_Perf`
|
||||
|
||||
```st
|
||||
VAR_GLOBAL
|
||||
// 1000-DINT array — exercised by the bulk Sum-read benchmark.
|
||||
aTags : ARRAY[1..1000] OF DINT;
|
||||
fbPerfChurn : FB_PerfChurn;
|
||||
END_VAR
|
||||
```
|
||||
|
||||
The XAE-form GVL ships at `PLC/GVLs/GVL_Perf.TcGVL`; import it into the PLC
|
||||
project alongside `GVL_Fixture`.
|
||||
|
||||
### POU: `FB_PerfChurn`
|
||||
|
||||
```st
|
||||
FUNCTION_BLOCK FB_PerfChurn
|
||||
VAR
|
||||
nIndex : INT := 1;
|
||||
END_VAR
|
||||
|
||||
GVL_Perf.aTags[nIndex] := GVL_Perf.aTags[nIndex] + 1;
|
||||
nIndex := nIndex + 1;
|
||||
IF nIndex > 1000 THEN
|
||||
nIndex := 1;
|
||||
END_IF
|
||||
```
|
||||
|
||||
The XAE-form POU ships at `PLC/POUs/FB_PerfChurn.TcPOU`. Wire it into `MAIN`
|
||||
so a value rotates each cycle:
|
||||
|
||||
```st
|
||||
PROGRAM MAIN
|
||||
VAR
|
||||
END_VAR
|
||||
|
||||
// existing GVL_Fixture line:
|
||||
GVL_Fixture.nCounter := GVL_Fixture.nCounter + 1;
|
||||
|
||||
// PR 2.1 — keep aTags moving so caches don't short-circuit the read.
|
||||
GVL_Perf.fbPerfChurn();
|
||||
```
|
||||
|
||||
### Running the perf tier
|
||||
|
||||
```powershell
|
||||
$env:TWINCAT_TARGET_HOST = '10.0.0.42'
|
||||
$env:TWINCAT_TARGET_NETID = '5.23.91.23.1.1'
|
||||
$env:TWINCAT_PERF = '1'
|
||||
dotnet test tests\ZB.MOM.WW.OtOpcUa.Driver.TwinCAT.IntegrationTests `
|
||||
--filter "Category=Performance"
|
||||
```
|
||||
|
||||
Without `TWINCAT_PERF=1` the perf test skips via `[TwinCATPerfFact]` even when
|
||||
the runtime is reachable — perf runs are opt-in to keep the default integration
|
||||
pass fast.
|
||||
|
||||
### Runtime ID
|
||||
|
||||
- TC3 PLC runtime 1 (AMS port `851`) — the smoke-test fixture defaults
|
||||
|
||||
Reference in New Issue
Block a user