ModernUO/Projects/Server.Tests/Tests/Network/Packets/Outgoing
Kamron Batman 65532ea887
feat: Adds optimized dynamic/static layout gumps (#1652)
# New Gump API
We are pleased to release a new API that is faster, allocates nearly zero memory, and still feels very similar to the original API. The API is broken into 3 types of gumps, dynamic, static with placeholders, and static without placeholders. 

### Dynamic Gumps
These gumps will inherit `DynamicGump` and are meant for gumps that have a dynamic layout. This includes specifying dynamic arguments to HtmlLocalized entries.

## Static Gumps 
Static gumps are those where the function to the build the layout is called only once and cached forever. They can optionally have placeholders. These placeholders allow the developer to specify the string values later, dynamically in a `BuildStrings` method on the gump. If a gump does not have any placeholders, the string entries will also be cached forever.

## Benchmarks
To make sure we were going in the right direction and not wasting time, we took copious benchmarks. Here are the final benchmarks for a really simple gump. 

Note:
* The majority of creating a gump is compressing the layout and the strings. Compressing each section takes ~6,000ns (12us total).

```cs
| Method                         | Mean         | Error        | StdDev       | Median       | Ratio | RatioSD | Gen0   | Allocated | Alloc Ratio |
|------------------------------- |-------------:|-------------:|-------------:|-------------:|------:|--------:|-------:|----------:|------------:|
| OldGump                        | 13,308.29 ns | 1,059.695 ns | 1,883.608 ns | 14,330.72 ns | 1.000 |    0.00 | 0.1526 |    2400 B |        1.00 |
| DynamicLayoutGump              | 13,357.86 ns |   129.144 ns |   226.185 ns | 13,323.60 ns | 1.029 |    0.17 |      - |      48 B |        0.02 |
| StaticLayoutDynamicStringsGump |  6,653.10 ns |    81.815 ns |   143.292 ns |  6,617.45 ns | 0.514 |    0.09 |      - |      40 B |        0.02 |
| StaticLayoutGump               |     86.33 ns |     0.760 ns |     1.350 ns |     86.07 ns | 0.007 |    0.00 | 0.0020 |      32 B |        0.01 |
```

# Non-Breaking Changes
* All gump components in the core have been moved to `Gumps/Legacy`.
* All legacy gumps will still inherit `Gump`, which now inherits `BaseGump`

# Special Thanks

Thank you to @stefanomerotta for considerable contributions/benchmarking/testing to make this effort a reality! We collectively went through over 10 iterations, but it is finally ready.
2024-04-25 22:40:30 -07:00
..
AccountPackets.cs fix(core): Adds IPv6 support (#348) 2020-12-19 00:27:39 -08:00
AccountPacketTests.cs fix: Reverts GetAccount to use IAccount. Adds IAccount to serialization. (#1565) 2023-10-25 19:17:57 -07:00
AttributeNormalizer.cs fix(core): Converts mobile incoming packet (#370) 2020-12-28 02:30:47 -08:00
CombatPackets.cs Fix bad serials (#304) 2020-11-08 12:09:26 -08:00
CombatPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
ContainerPackets.cs Converts Item & Entity Packets (#326) 2020-11-29 03:24:51 -08:00
ContainerPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
DamagePackets.cs Fix bad serials (#304) 2020-11-08 12:09:26 -08:00
DamagePacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
EffectPackets.cs Updates Light Packets & World Loading (#316) 2020-11-17 00:46:06 -08:00
EffectPacketTests.cs feat: Adds a memory mirrored ring buffer for networking. (#1533) 2023-10-09 00:57:53 -07:00
EquipmentPackets.cs Updates Light Packets & World Loading (#316) 2020-11-17 00:46:06 -08:00
EquipmentPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
GumpPackets.cs fix: Removes support for v4 Client and old gump packet. (#1739) 2024-04-24 19:39:37 -07:00
GumpPacketTests.cs feat: Adds optimized dynamic/static layout gumps (#1652) 2024-04-25 22:40:30 -07:00
ItemPackets.cs Converts Item & Entity Packets (#326) 2020-11-29 03:24:51 -08:00
ItemPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
LightPackets.cs Updates Light Packets & World Loading (#316) 2020-11-17 00:46:06 -08:00
LightPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
MapPackets.cs Updates map packets (#319) 2020-11-17 20:58:28 -08:00
MapPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
MenuPackets.cs Updates menu packets (#320) 2020-11-17 21:47:00 -08:00
MenuPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
MessagePackets.cs fix(core): Adds object help response packets (#336) 2020-12-07 21:19:21 -08:00
MessagePacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
MobilePackets.cs fix: Fixes spell mechanics and misc bugs (#1118) 2022-07-14 22:01:59 -07:00
MobilePacketTests.cs fix: Removes support for v4 Client and old gump packet. (#1739) 2024-04-24 19:39:37 -07:00
MovementPackets.cs feat: Adds a movement throttle system. Removes Fastwalk system. (#1511) 2023-09-27 20:53:22 -07:00
MovementPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
PlayerPackets.cs fix: Fixes boat movement & moves weapon ability out of core (#750) 2021-08-30 21:30:09 -07:00
PlayerPacketTests.cs fix: Fixes various mobile packets and setting serials (#1618) 2023-11-26 00:42:15 -08:00
SecureTradePackets.cs fix(networking): Standardizes SecureTrade packets (#577) 2021-04-16 11:26:21 -07:00
SecureTradePacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
TargetPackets.cs Converts targeting packets (#330) 2020-11-29 23:01:31 -08:00
TargetPacketsTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
VendorBuyPackets.cs chore: Cleans up pattern checks. (#892) 2021-12-24 15:53:59 -08:00
VendorBuyPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
VendorSellPackets.cs chore: Updates copyright (#1448) 2023-08-09 09:09:26 -07:00
VendorSellPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00
VirtualHairPackets.cs fix(core): Converts virtual hair packets (#388) 2021-01-05 22:14:54 -08:00
VirtualHairPacketTests.cs chore: Cleans up unused imports (#1550) 2023-10-15 11:45:42 -07:00