/* * private void PrepareTestPreBuildPhotonMapper() * { * ISaveablePhotonMapperBuilder builder = PhotonMapperBuilderFactory.CreateSaveableBiserializer("PreBuildedMapper", "PreBuildedMapper.dll", "PreBuildTestAssembly"); * * builder.RegisterContract<SpeedComparisonContract>(); * * SimpleCustomTypeBiserializerRegistry registry = new SimpleCustomTypeBiserializerRegistry(); * registry.RegisterCustomTypeBiserializer<Guid, GuidBiserializer>(); * registry.RegisterCustomTypeBiserializer<Vector2, Vector2Biserializer>(); * * builder.SaveAsDll(); * } * * private void TestPreBuildPhotonMapper() * { * SimpleCustomTypeBiserializerRegistry registry = new SimpleCustomTypeBiserializerRegistry(); * registry.RegisterCustomTypeBiserializer<Guid, GuidBiserializer>(); * registry.RegisterCustomTypeBiserializer<Vector2, Vector2Biserializer>(); * * APhotonMapper mapper = new PreBuildTestAssembly.PhotonMapper(registry); * * SpeedComparisonContract contract = CreateSpeedComparisonContract(); * * Stopwatch sw = new Stopwatch(); * for (int i = 0; i < WarmupIterations; i++) * { * mapper.ToDictionary(contract); * } * sw.Restart(); * for (int i = 0; i < TotalIterations; i++) * { * mapper.ToDictionary(contract); * } * sw.Stop(); * Console.WriteLine($"PreBuildTestAssembly.ToDictionary: {sw.Elapsed.TotalMilliseconds}ms ({sw.Elapsed.TotalMilliseconds / TotalIterations}ms/iterations)"); * * Dictionary<byte, object> parameters = mapper.ToDictionary(contract); * for (int i = 0; i < WarmupIterations; i++) * { * mapper.FromDictionary<SpeedComparisonContract>(parameters); * } * sw.Restart(); * for (int i = 0; i < TotalIterations; i++) * { * mapper.FromDictionary<SpeedComparisonContract>(parameters); * } * Console.WriteLine($"PreBuildTestAssembly.FromDictionary: {sw.Elapsed.TotalMilliseconds}ms ({sw.Elapsed.TotalMilliseconds / TotalIterations}ms/iterations)"); * sw.Stop(); * } */ private void PrepareTestPhotonMapper() { IPhotonMapperBuilder builder = PhotonMapperBuilderFactory.CreatePhotonMapper(); builder.RegisterContract <SpeedComparisonContract>(); SimpleCustomTypeBiserializerRegistry registry = new SimpleCustomTypeBiserializerRegistry(); registry.RegisterCustomTypeBiserializer <Guid, GuidBiserializer>(); registry.RegisterCustomTypeBiserializer <Vector2, Vector2Biserializer>(); _mapper = builder.ReleaseMapper(registry); }
public void RunExamples() { ISaveablePhotonMapperBuilder builder = PhotonMapperBuilderFactory.CreateSaveablePhotonMapper("TestAsm", "myFile.dll", "TestPrefix"); builder.RegisterContract <SimpleContracts.SimpleContract>(); builder.RegisterContract <SimpleContractWithCustomType>(); builder.RegisterContract <ObjectSay>(); builder.SaveAsDll(); SimpleCustomTypeBiserializerRegistry biserializerRegistry = new SimpleCustomTypeBiserializerRegistry(); biserializerRegistry.RegisterCustomTypeBiserializer <Guid, GuidBiserializer>(); biserializerRegistry.RegisterCustomTypeBiserializer <FixPoint, FixPointBiserializer>(); biserializerRegistry.RegisterCustomTypeBiserializer <Vector2, Vector2Biserializer>(); _photonMapper = builder.ReleaseMapper(biserializerRegistry); RunSimpleContract(); RunSimpleContractWithCustomType(); RunObjectSay(); }