public void RemoveTest()
        {
            int radix = 5;
            int arraySize = 10;
            PartitionedMemoryCacher<string> mc = new PartitionedMemoryCacher<string>(radix, arraySize);

            mc.Add(0, "sıfır");
            mc.Add(1, "bir");

            //init contidions
            Assert.AreEqual(2, mc.Count);
            Assert.AreEqual(1, mc[0].Count);
            Assert.AreEqual(1, mc[1].Count);

            mc.Remove(0);

            //phase 1 conditions
            Assert.AreEqual(1, mc.Count);
            Assert.AreEqual(0, mc[0].Count);
            Assert.AreEqual(1, mc[1].Count);

            mc.Remove(1);

            //phase 2 conditions
            Assert.AreEqual(0, mc.Count);
            Assert.AreEqual(0, mc[0].Count);
            Assert.AreEqual(0, mc[1].Count);
        }
        public void AddTest()
        {
            int radix = 5;
            int arraySize = 10;
            PartitionedMemoryCacher<string> mc = new PartitionedMemoryCacher<string>(radix, arraySize);

            mc.Add(0, "sıfır");
            mc.Add(1, "bir");
            mc.Add(2, "iki");
            mc.Add(3, "üç");
            mc.Add(4, "dört");
            mc.Add(5, "beş");
            mc.Add(6, "altı");

            Assert.AreEqual(7, mc.Count);

            Assert.AreEqual(2, mc[0].Count);

            Assert.AreEqual(2, mc[1].Count);
            Assert.AreEqual(1, mc[2].Count);
            Assert.AreEqual(1, mc[3].Count);
            Assert.AreEqual(1, mc[4].Count);
        }
示例#3
0
        public override void Run()
        {
            PartitionedMemoryCacher<string> d = new PartitionedMemoryCacher<string>(CONCURRENCY_LEVEL, ARRAY_SIZE);
            __sw.Reset();
            __sw.Start();

            Parallel.For(0, 1000000, i => d.Add(i, "abc"));

            __sw.Stop();

            Console.WriteLine("Parallel Add PartitionedMemoryCacher: {0}", __sw.ElapsedTicks);
        }
示例#4
0
        public override void Run()
        {
            PartitionedMemoryCacher<string> d = new PartitionedMemoryCacher<string>(CONCURRENCY_LEVEL, ARRAY_SIZE);
            __sw.Reset();
            __sw.Start();

            for (int i = 0; i < 1000000; i++)
            {
                d.Add(i, "abc");
            }

            __sw.Stop();

            Console.WriteLine("Loop Add PartitionedMemoryCacher: {0}", __sw.ElapsedTicks);
        }
示例#5
0
        public override void Run()
        {
            PartitionedMemoryCacher<string> d = new PartitionedMemoryCacher<string>(CONCURRENCY_LEVEL, ARRAY_SIZE);

            for (int i = 0; i < 1000000; i++)
            {
                d.Add(i, "abc");
            }

            string s = string.Empty;

            __sw.Reset();
            __sw.Start();

            Parallel.For(0, 1000000, i => d.Set(i, s));

            __sw.Stop();

            Console.WriteLine("Parallel Update PartitionedMemoryCacher: {0}", __sw.ElapsedTicks);
        }