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
33 lines
998 B
C#
33 lines
998 B
C#
using System;
|
|
|
|
namespace Robust.Shared.Serialization.Manager.Result
|
|
{
|
|
public abstract class DeserializationResult
|
|
{
|
|
public abstract object? RawValue { get; }
|
|
|
|
public abstract DeserializationResult PushInheritanceFrom(DeserializationResult source);
|
|
|
|
public abstract DeserializationResult Copy();
|
|
|
|
public abstract void CallAfterDeserializationHook();
|
|
|
|
public static DeserializationResult Value<T>(T value) where T : notnull
|
|
{
|
|
var type = typeof(DeserializedValue<>).MakeGenericType(value.GetType());
|
|
return (DeserializationResult) Activator.CreateInstance(type, value)!;
|
|
}
|
|
|
|
public T Cast<T>() where T : DeserializationResult
|
|
{
|
|
if (this is T value) return value;
|
|
throw new InvalidDeserializedResultTypeException<T>(GetType());
|
|
}
|
|
}
|
|
|
|
public abstract class DeserializationResult<T> : DeserializationResult
|
|
{
|
|
public abstract T Value { get; }
|
|
}
|
|
}
|