Exemple #1
0
        public CloneBenchmark()
        {
            this.testClass       = new() { Y = 2 };
            this.testClass.X     = 1;
            this.testClass.Array = new int[] { 3, 4, 5, 6, 7, 8, 9, 10, };
            this.testClass.List  = new() { 11, 12, 13, 14, 15, 16 };
        }

        [GlobalSetup]
Exemple #2
0
        public CloneTestClass Clone_Raw()
        {
            var t = new CloneTestClass();

            t.X     = this.testClass.X;
            t.Y     = this.testClass.Y;
            t.Array = new int[this.testClass.Array.Length];
            // Array.Copy(this.testClass.Array, t.Array, this.testClass.Array.Length);
            for (var n = 0; n < this.testClass.Array.Length; n++)
            {
                t.Array[n] = this.testClass.Array[n];
            }

            if (this.testClass.List == null)
            {
                t.List = null !;
            }
            else
            {
                t.List = new(this.testClass.List);
            }

            return(t);
        }