コード例 #1
0
        public void SingleSetable_Set_Test()
        {
            var singleSetable = new SingleSetable();

            Assert.False(singleSetable.Set());
            Assert.True(singleSetable.Set());
            Assert.True(singleSetable.Set());
        }
コード例 #2
0
        public void SingleSetable_MultibleCheck_Test()
        {
            var sw            = new Stopwatch();
            var singleSetable = new SingleSetable();

            sw.Reset();
            sw.Start();
            for (var i = 0; i < 10000; i++)
            {
                singleSetable.Set();
            }

            sw.Stop();
            Console.WriteLine("ElapsedTicks {0}", sw.ElapsedTicks);

            var singleSetableLock = new SingleSetableLock();

            sw.Reset();
            sw.Start();
            for (var i = 0; i < 10000; i++)
            {
                singleSetableLock.Set();
            }

            sw.Stop();
            Console.WriteLine("ElapsedTicks {0}", sw.ElapsedTicks);
        }