Exemplo n.º 1
0
        void StringTest()
        {
            //byte[] <-> byte
            //직접 쓴다.

            //byte[] <- short, Int16
            string _data = "12.345f";

            byte[] _b1    = new byte[10];
            byte[] _b2    = new byte[10];
            string _data1 = string.Empty;
            string _data2 = string.Empty;

            dt[0] = DateTime.Now;
            for (int i = 0; i < loop; i++)
            {
                CUtil.SetString(_b1, 0, _data);
            }

            dt[1] = DateTime.Now;
            for (int i = 0; i < loop; i++)
            {
                CUtil.SetString2(_b2, 0, ref _data);
            }

            dt[2] = DateTime.Now;
            for (int i = 0; i < loop; i++)
            {
                _data1 = CUtil.GetString(_b1, 0);
            }
            dt[3] = DateTime.Now;
            for (int i = 0; i < loop; i++)
            {
                CUtil.GetString2(_b2, 0, out _data2);
            }
            dt[4] = DateTime.Now;


            Console.WriteLine("============");
            Display(_b1);
            Display(_b2);
            Console.WriteLine("_data:{0} _data1:{1} _data2:{2}", _data, _data1, _data2);

            Console.WriteLine("SetString:{0}", ((TimeSpan)(dt[1] - dt[0])).Milliseconds);
            Console.WriteLine("SetString2:{0}", ((TimeSpan)(dt[2] - dt[1])).Milliseconds);
            Console.WriteLine("GetString:{0}", ((TimeSpan)(dt[3] - dt[2])).Milliseconds);
            Console.WriteLine("GetString2:{0}", ((TimeSpan)(dt[4] - dt[3])).Milliseconds);
        }
Exemplo n.º 2
0
        void IntTest()
        {
            //byte[] <-> byte
            //직접 쓴다.

            //byte[] <- short, Int16
            int _data = 256;

            byte[] _b1    = new byte[8];
            byte[] _b2    = new byte[8];
            int    _data1 = 0;
            int    _data2 = 0;

            dt[0] = DateTime.Now;
            for (int i = 0; i < loop; i++)
            {
                CUtil.SetInt(_b1, 0, _data);
            }

            dt[1] = DateTime.Now;
            for (int i = 0; i < loop; i++)
            {
                CUtil.SetInt2(_b2, 0, _data);
            }

            dt[2] = DateTime.Now;
            for (int i = 0; i < loop; i++)
            {
                _data1 = CUtil.GetInt(_b1, 0);
            }
            dt[3] = DateTime.Now;
            for (int i = 0; i < loop; i++)
            {
                _data2 = CUtil.GetInt2(_b2, 0);
            }
            dt[4] = DateTime.Now;

            Console.WriteLine("============");
            Display(_b1);
            Display(_b2);
            Console.WriteLine("_data:{0} _data1:{1} _data2:{2}", _data, _data1, _data2);

            Console.WriteLine("SetInt:{0}", ((TimeSpan)(dt[1] - dt[0])).Milliseconds);
            Console.WriteLine("SetInt2:{0}", ((TimeSpan)(dt[2] - dt[1])).Milliseconds);
            Console.WriteLine("GetInt:{0}", ((TimeSpan)(dt[3] - dt[2])).Milliseconds);
            Console.WriteLine("GetInt2:{0}", ((TimeSpan)(dt[4] - dt[3])).Milliseconds);
        }