Ejemplo n.º 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            List <(string, decimal)> lst = new List <(string, decimal)>();

            EntityUtility.FileListInArrayWithPower(",1101(sd),1202*3,1301(手段)*.5,5202-1,4107*2.5,1703。", lst, 1);
            var t1 = typeof(List <int>);
            var t2 = typeof(List <short>);
            ReaderWriterLockSlim lockSlim = new ReaderWriterLockSlim(LockRecursionPolicy.SupportsRecursion);

            lockSlim.EnterWriteLock();
            lockSlim.EnterReadLock();
            lockSlim.ExitWriteLock();
            if (null == f)
            {
                f = 0.5f;
            }
            var       t  = OwInitializer.BeginInitialize();
            Matrix4x4 m1 = new Matrix4x4(
                1, 2, 3, 4,
                2, 3, 4, 5,
                3, 4, 5, 6,
                4, 5, 6, 7);
            Matrix4x4 m2 = new Matrix4x4(
                0, 2, 3, 4,
                2, 3, 4, 5,
                3, 4, 5, 6,
                4, 5, 6, 7);
            int    rank0 = 100; //200基准30ms,1000基准5s
            Random rnd   = new Random();
            var    mm    = new MmoCanges <FastChangePositionBase>();
            List <(Vector3, FastChangePositionBase)> dispare = new List <(Vector3, FastChangePositionBase)>();
            List <(Vector3, FastChangePositionBase)> moved   = new List <(Vector3, FastChangePositionBase)>();
            List <(Vector3, FastChangePositionBase)> distroy = new List <(Vector3, FastChangePositionBase)>();

            FastChangePositionBase[] arys = new FastChangePositionBase[2000];
            for (int i = 0; i < 2000; i++)
            {
                var tmp = new FastChangePositionBase()
                {
                    Position = new Vector3((float)rnd.NextDouble() * 400, (float)rnd.NextDouble() * 400, 0)
                };
                arys[i] = tmp;
                mm.Change(tmp, 1, dispare, moved, distroy);
                dispare.Clear();
                moved.Clear();
                distroy.Clear();
            }
            var       bm = ObjectPool.Default;
            Stopwatch sw = Stopwatch.StartNew();

            try
            {
                Parallel.For(0, 20000, new ParallelOptions()
                {
                    MaxDegreeOfParallelism = (int)(Environment.ProcessorCount * 1),
                }, c =>
                {
                    using (var ch = ObjectPool.TakeObject <ClearHelper>())
                    {
                        var tmp      = arys[rnd.Next(2000)];
                        tmp.Position = new Vector3(tmp.Position.X + (float)rnd.NextDouble() * 2 - 1f, tmp.Position.Y + (float)rnd.NextDouble() * 2 - 1f, 0);
                        var l1       = ch.TakeObjectAndReturn <List <(Vector3, FastChangePositionBase)> >();
                        var l2       = ch.TakeObjectAndReturn <List <(Vector3, FastChangePositionBase)> >();
                        var l3       = ch.TakeObjectAndReturn <List <(Vector3, FastChangePositionBase)> >();
                        mm.Change(tmp, 40, l1, l2, l3);
                        l1.Clear();
                        l2.Clear();
                        l3.Clear();
                    }
                });