public static unsafe void WriteCppArrayElements(int length, int maxi, Vehicle v1)
        {
            try
              {
            System.TimeSpan ts;
            System.DateTime begin;

            int i = 0;
            float* af = (float*)v1.InfoArrayBase();
            float lf = 0.0F;

            Trace("Direct C++ array write access from C# 'af[i] = lf' loop...\n");
            begin = System.DateTime.Now;
            for (i = 0; i < maxi; ++i)
            {
              af[i % length] = lf;
            }
            ts = System.DateTime.Now - begin;
            ReportTiming("float", ts, (uint)maxi);

            Trace("Unchecked vtable write access 'v1.SetInfoArrayElementUnchecked(i, lf)' loop...\n");
            begin = System.DateTime.Now;
            for (i = 0; i < maxi; ++i)
            {
              v1.TSetInfoArrayElementUnchecked(i % length, lf);
            }
            ts = System.DateTime.Now - begin;
            ReportTiming("float", ts, (uint)maxi);

            Trace("Unchecked vtable read access 'lf = v1.GetInfoArrayElementUnchecked(i)' loop...\n");
            begin = System.DateTime.Now;
            for (i = 0; i < maxi; ++i)
            {
              lf = v1.TGetInfoArrayElementUnchecked(i % length);
            }
            ts = System.DateTime.Now - begin;
            ReportTiming("float", ts, (uint)maxi);

            Trace("Checked vtable write access 'v1.SetInfoArrayElementChecked(i, lf)' loop...\n");
            begin = System.DateTime.Now;
            for (i = 0; i < maxi; ++i)
            {
              v1.TSetInfoArrayElementChecked(i % length, lf);
            }
            ts = System.DateTime.Now - begin;
            ReportTiming("float", ts, (uint)maxi);

            Trace("Checked vtable read access 'lf = v1.GetInfoArrayElementChecked(i)' loop...\n");
            begin = System.DateTime.Now;
            for (i = 0; i < maxi; ++i)
            {
              lf = v1.TGetInfoArrayElementChecked(i % length);
            }
            ts = System.DateTime.Now - begin;
            ReportTiming("float", ts, (uint)maxi);
              }
              catch (Exception exc)
              {
            Trace(exc.ToString());
            throw;
              }
        }
Example #2
0
        public unsafe static void WriteCppArrayElements(int length, int maxi, Vehicle v1)
        {
            try
            {
                System.TimeSpan ts;
                System.DateTime begin;

                int    i  = 0;
                float *af = (float *)v1.InfoArrayBase();
                float  lf = 0.0F;


                Trace("Direct C++ array write access from C# 'af[i] = lf' loop...\n");
                begin = System.DateTime.Now;
                for (i = 0; i < maxi; ++i)
                {
                    af[i % length] = lf;
                }
                ts = System.DateTime.Now - begin;
                ReportTiming("float", ts, (uint)maxi);


                Trace("Unchecked vtable write access 'v1.SetInfoArrayElementUnchecked(i, lf)' loop...\n");
                begin = System.DateTime.Now;
                for (i = 0; i < maxi; ++i)
                {
                    v1.TSetInfoArrayElementUnchecked(i % length, lf);
                }
                ts = System.DateTime.Now - begin;
                ReportTiming("float", ts, (uint)maxi);


                Trace("Unchecked vtable read access 'lf = v1.GetInfoArrayElementUnchecked(i)' loop...\n");
                begin = System.DateTime.Now;
                for (i = 0; i < maxi; ++i)
                {
                    lf = v1.TGetInfoArrayElementUnchecked(i % length);
                }
                ts = System.DateTime.Now - begin;
                ReportTiming("float", ts, (uint)maxi);


                Trace("Checked vtable write access 'v1.SetInfoArrayElementChecked(i, lf)' loop...\n");
                begin = System.DateTime.Now;
                for (i = 0; i < maxi; ++i)
                {
                    v1.TSetInfoArrayElementChecked(i % length, lf);
                }
                ts = System.DateTime.Now - begin;
                ReportTiming("float", ts, (uint)maxi);


                Trace("Checked vtable read access 'lf = v1.GetInfoArrayElementChecked(i)' loop...\n");
                begin = System.DateTime.Now;
                for (i = 0; i < maxi; ++i)
                {
                    lf = v1.TGetInfoArrayElementChecked(i % length);
                }
                ts = System.DateTime.Now - begin;
                ReportTiming("float", ts, (uint)maxi);
            }
            catch (Exception exc)
            {
                Trace(exc.ToString());
                throw;
            }
        }