mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-15 03:30:53 +01:00
* Add Robust.Benchmarks and read string benchmark
* Separate serialization manager methods, use compiled lambdas to call manager read
4 us > 200 ns
* Add int and data definition with string benchmarks
* Make serialization population use expressions to create definitions
* Make benchmark classes internal and create seed data definition
* Add complex data definition read benchmark
* Create primitive serializers, remove primitive special case
| Method | Mean | Error | StdDev |
|----------------------- |------------:|----------:|----------:|
| ReadString | 227.1 ns | 4.47 ns | 5.65 ns |
| ReadInteger | 245.4 ns | 4.82 ns | 6.26 ns |
| ReadDataDefWithString | 804.7 ns | 15.27 ns | 16.34 ns |
| ReadSeedDataDefinition | 15,846.8 ns | 312.89 ns | 773.39 ns |
* Remove testing code
* Setup delegates during initialize
* Revert "Setup delegates during initialize"
This reverts commit 7ff4d4eaaa.
* Store delegates in a concurrent dictionary because I really cannot be arsed to generate them on initialize at this point
55 lines
1.4 KiB
C#
55 lines
1.4 KiB
C#
namespace Robust.Shared.Serialization.Manager.Result
|
|
{
|
|
public class DeserializedValue : DeserializationResult
|
|
{
|
|
public DeserializedValue(object? value)
|
|
{
|
|
RawValue = value;
|
|
}
|
|
|
|
public override object? RawValue { get; }
|
|
|
|
public override DeserializationResult PushInheritanceFrom(DeserializationResult source)
|
|
{
|
|
return source.Copy().Cast<DeserializedValue>();
|
|
}
|
|
|
|
public override DeserializationResult Copy()
|
|
{
|
|
return new DeserializedValue(RawValue);
|
|
}
|
|
|
|
public override void CallAfterDeserializationHook()
|
|
{
|
|
if (RawValue is ISerializationHooks hooks) hooks.AfterDeserialization();
|
|
}
|
|
}
|
|
|
|
public class DeserializedValue<T> : DeserializationResult<T>
|
|
{
|
|
public DeserializedValue(T value)
|
|
{
|
|
Value = value;
|
|
}
|
|
|
|
public override T Value { get; }
|
|
|
|
public override object? RawValue => Value;
|
|
|
|
public override DeserializationResult PushInheritanceFrom(DeserializationResult source)
|
|
{
|
|
return source.Copy().Cast<DeserializedValue<T>>();
|
|
}
|
|
|
|
public override DeserializationResult Copy()
|
|
{
|
|
return new DeserializedValue<T>(Value);
|
|
}
|
|
|
|
public override void CallAfterDeserializationHook()
|
|
{
|
|
if (Value is ISerializationHooks hooks) hooks.AfterDeserialization();
|
|
}
|
|
}
|
|
}
|