Ejemplo n.º 1
0
        static void RunConcurrentDictionary()
        {
            var threads = new List <Task>();
            var sw      = new Stopwatch();

            var ch = new DistinctConcurrentBag <Guid>();

            sw.Start();

            for (int runCount = 0; runCount < TestRunCount; runCount++)
            {
                threads.Add(Task.Factory.StartNew(() => ProcessConcurrentDictionary(ch, TestRunCollectionCount)));
            }

            Task.WaitAll(threads.ToArray());

            sw.Stop();


            var test = XmlHelper.Serialize(ch);

            var testResult = XmlHelper.Deserialize <DistinctConcurrentBag <Guid> >(test);

            var json = ch.ToJson();

            var jsonResult = json.FromJson <DistinctConcurrentBag <Guid> >();


            var    count = ch.Count;
            double avg   = sw.ElapsedMilliseconds / count;

            Console.WriteLine("CB test took {0} milliseconds, Count={1}-{2}.", sw.ElapsedMilliseconds, count, avg);
            Console.WriteLine();
        }
Ejemplo n.º 2
0
        public void Creating02()
        {
            var fakePeople = new DistinctConcurrentBag <PersonProper>();

            this.personProperCollection.ForEach(p => { fakePeople.Add(p); });

            base.Consumer.Consume(fakePeople);
        }
Ejemplo n.º 3
0
        private static void ProcessConcurrentDictionary(DistinctConcurrentBag <Guid> ch, int collectionCount)
        {
            Console.WriteLine("DCB Collection Count={0}...", collectionCount);

            for (var iterationCount = 0; iterationCount < collectionCount; iterationCount++)
            {
                ch.Add(Guid.NewGuid());
            }
        }
Ejemplo n.º 4
0
        public void Creating01()
        {
            var fakePeople = new DistinctConcurrentBag <PersonProper>(this.personProperCollection);

            base.Consumer.Consume(fakePeople);
        }
Ejemplo n.º 5
0
        public override void Setup()
        {
            base.Setup();

            this._distinctConcurrentBag = new DistinctConcurrentBag <PersonProper>(RandomData.GeneratePersonCollection <PersonProper>(this.CollectionCount));
        }