Пример #1
0
        public Dictionary <string, long> MeasureMemory(Dictionary <string, ISerializer> serializers, int modelsCount)
        {
            var model = DataPreparer.GenerateModel(1, modelsCount);
            var res   = new Dictionary <string, long>();

            foreach (var serializer in serializers)
            {
                var payload = serializer.Value.Serialize <Model>(model);
                res[serializer.Key] = payload.Length;
            }
            return(res);
        }
Пример #2
0
        public static void Test(IDictionary <string, ISerializer> serializers)
        {
            foreach (var serializer in serializers)
            {
                var model = DataPreparer.GenerateModel(1, 10);

                var s            = serializer.Value;
                var data         = s.Serialize <Model>(model);
                var deserialized = s.Deserialize <Model>(data);
                model.Compare(deserialized);
            }
        }
Пример #3
0
        public Dictionary <string, long> MeasureTime(Dictionary <string, ISerializer> serializers, int modelsCount)
        {
            var models = DataPreparer.GenerateData(modelsCount);
            var res    = new Dictionary <string, long>();

            foreach (var serializer in serializers)
            {
                var sw = new Stopwatch();
                sw.Start();
                foreach (var model in models)
                {
                    var payload      = serializer.Value.Serialize <Model>(model);
                    var deserialized = serializer.Value.Deserialize <Model>(payload);
                }
                sw.Stop();
                res[serializer.Key] = sw.ElapsedMilliseconds;
            }
            return(res);
        }