public static Cadastro CriarClientes(int times) { Cadastro.Types.Cliente[] clientes = new Cadastro.Types.Cliente[times]; for (int i = 0; i < times; i++) { clientes[i] = CriarCliente(); } var cadastro = new Cadastro { Clientes = { clientes } }; return(cadastro); }
public void SerializarEDeserializarPayloadsDeCliente(int quantity) { Stopwatch watch = Stopwatch.StartNew(); TimeSpan tsSerialization = new TimeSpan(); TimeSpan tsDeSerialization = new TimeSpan(); for (int i = 0; i < quantity; i++) { var cliente = StubsProtoBuf.CriarCliente(); var stream = Serialize(cliente); watch.Stop(); tsSerialization += watch.Elapsed; watch.Restart(); Cadastro.Types.Cliente copy = Cadastro.Types.Cliente.Parser.ParseFrom(stream); tsDeSerialization += watch.Elapsed; watch.Restart(); } Console.WriteLine("RunTime " + typeof(ProtobufSimulator).Name + " time accumulated to Serialize " + quantity + " Objects " + tsSerialization.ToFormatedString()); Console.WriteLine("RunTime " + typeof(ProtobufSimulator).Name + " time accumulated to Deserialize " + tsDeSerialization.ToFormatedString()); }