Exemple #1
0
        /// <summary>
        /// Returns a string that represents the current object.
        /// </summary>
        /// <returns>
        /// A string that represents the current object.
        /// </returns>
        public override string ToString()
        {
#if !NETCF && !SILVERLIGHT
            return(_stopwatch.ToString());
#else
            return(base.ToString());
#endif
        }
Exemple #2
0
 void Button3Click(object sender, EventArgs e)
 {
     System.Diagnostics.Stopwatch _stw = new System.Diagnostics.Stopwatch();
     _stw.Start();
     for (int i = 0; i < 1000; i++)
     {
         string q = " select Ten from tblTuDienDonViHanhChinhVN ";
         OpenCon();
         com.CommandText = q;
         string a = com.ExecuteScalar().ToString();
         CloseCon();
     }
     _stw.Stop();
     MessageBox.Show("Yeee!.....\n" + _stw.ToString());
 }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            Form1.SinCalculator          Test = new Form1.SinCalculator(2000);
            System.Diagnostics.Stopwatch sw   = new System.Diagnostics.Stopwatch();
            sw.Start();
            for (int u = 0; u < 500; u++)
            {
                label1.Text = sw.ToString();
                Random   rand = new Random();
                int[]    mas1 = new int[1000];
                double[] mas2 = new double[1000];
                for (int i = 0; i < 1000; i++)
                {
                    mas1[i] = rand.Next();
                    mas2[i] = rand.NextDouble();
                }

                for (int i = mas1.Length - 1; i > 0; i--)
                {
                    for (int j = 0; j < i; j++)
                    {
                        if (mas1[j] > mas1[j + 1])
                        {
                            double t = mas2[i];
                            mas2[i] = mas2[mas2.Length - i];
                            mas2[mas2.Length - i] = t;
                            int tmp = mas1[j];
                            mas1[j]     = mas1[j + 1];
                            mas1[j + 1] = tmp;
                        }
                    }
                }
                ///////////////

                for (int i = 0; i < 200; i++)
                {
                    Test.Sin(20).ToString();
                }
            }
            sw.Stop();
            TimeSpan ts;

            ts          = sw.Elapsed;
            label1.Text = "Ваш компьютер справился с этим за " + ts.Seconds.ToString() + "." + ts.Milliseconds.ToString() + " секунд. Нелохо.";
            label2.Text = "Более точный результат: " + ts.ToString();
        }
Exemple #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            Form1.SinCalculator Test = new Form1.SinCalculator(2000);
            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            for (int u = 0; u < 500; u++)
            {
                label1.Text = sw.ToString();
                Random rand = new Random();
                int[] mas1 = new int[1000];
                double[] mas2 = new double[1000];
                for (int i = 0; i < 1000; i++)
                {
                    mas1[i] = rand.Next();
                    mas2[i] = rand.NextDouble();
                }

                for (int i = mas1.Length - 1; i > 0; i--)
                    for (int j = 0; j < i; j++)
                        if (mas1[j] > mas1[j + 1])
                        {
                            double t = mas2[i];
                            mas2[i] = mas2[mas2.Length - i];
                            mas2[mas2.Length - i] = t;
                            int tmp = mas1[j];
                            mas1[j] = mas1[j + 1];
                            mas1[j + 1] = tmp;
                        }
                ///////////////

                for (int i = 0; i < 200; i++)
                    Test.Sin(20).ToString();
            }
            sw.Stop();
            TimeSpan ts;
            ts = sw.Elapsed;
            label1.Text = "Ваш компьютер справился с этим за " + ts.Seconds.ToString() +"." + ts.Milliseconds.ToString() + " секунд. Нелохо.";
            label2.Text = "Более точный результат: " + ts.ToString();
        }
 /// <summary>
 /// Returns a string that represents the current object.
 /// </summary>
 /// <returns></returns>
 public override string ToString()
 {
     return(InnerWatch.ToString());
 }
Exemple #6
0
        static void Main()
        {
            string time = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt");

            Console.WriteLine("Would you like to do elapsed mode or countdown mode?");
            string response = Console.ReadLine();

            Console.Clear();


            if (response.ToLower() == "elapsed")
            {
                time = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt");
                System.Diagnostics.Stopwatch elapsed = new System.Diagnostics.Stopwatch();
                Console.CursorVisible = false;
                Console.WriteLine(time);
                elapsed.Start();
                while (time != elapsed.ToString())
                {
                    Console.SetCursorPosition(0, Console.CursorTop);
                    Console.Write(elapsed.Elapsed);
                }
            }
            else if (response.ToLower() == "countdown")
            {
                Console.WriteLine("What time would you like to stop the clock at? (MM-dd-yyyy hh:mm:ss tt)");
                string stopTime = Console.ReadLine();
                Console.Clear();
                Console.WriteLine(stopTime);
                Console.CursorVisible = false;
                int stopMonth = Int32.Parse(stopTime.Substring(0, 2));
                int stopDay   = Int32.Parse(stopTime.Substring(stopTime.IndexOf("-") + 1, 2));
                stopTime = stopTime.Remove(0, stopTime.IndexOf("-") + 1);
                int stopYear = Int32.Parse(stopTime.Substring(stopTime.IndexOf("-") + 1, 4));
                stopTime = stopTime.Remove(0, stopTime.IndexOf("-") + 1);
                int stopHour = Int32.Parse(stopTime.Substring(stopTime.IndexOf(" ") + 1, 2));
                stopTime = stopTime.Remove(0, stopTime.IndexOf(" ") + 1);
                int stopMinute = Int32.Parse(stopTime.Substring(stopTime.IndexOf(":") + 1, 2));
                stopTime = stopTime.Remove(0, stopTime.IndexOf(":") + 1);
                int stopSecond = Int32.Parse(stopTime.Substring(stopTime.IndexOf(":") + 1, 2));
                stopTime = stopTime.Remove(0, stopTime.IndexOf(":") + 1);
                while (time != stopTime)
                {
                    time = DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt");

                    int curMonth = Int32.Parse(time.Substring(0, 2));
                    time = time.Remove(0, 2);
                    int curDay = Int32.Parse(time.Substring(time.IndexOf("-") + 1, 2));
                    time = time.Remove(time.IndexOf("-"), 2);
                    int curYear = Int32.Parse(time.Substring(time.IndexOf("-") + 1, 4));
                    time = time.Remove(time.IndexOf("-"), 4);
                    int curHour = Int32.Parse(time.Substring(time.IndexOf(" ") + 1, 2));
                    time = time.Remove(time.IndexOf(" "), 2);
                    int curMinute = Int32.Parse(time.Substring(time.IndexOf(":") + 1, 2));
                    time = time.Remove(time.IndexOf(":"), 2);
                    int curSecond = Int32.Parse(time.Substring(time.IndexOf(":") + 1, 2));
                    time = time.Remove(time.IndexOf(":"), 2);

                    Console.SetCursorPosition(0, Console.CursorTop);
                    Console.Write($"{(stopMonth - curMonth)}-{(stopDay - curDay)}-{(stopYear - curYear)} {(stopHour - curHour)}:{(stopMinute - curMinute)}:{(stopSecond - curSecond)}     ");
                    Console.WriteLine(" ");
                    Console.SetCursorPosition(0, Console.CursorTop);
                    Console.Write(DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt"));
                    Console.SetCursorPosition(0, Console.CursorTop - 1);
                }
            }

            Console.WriteLine(" ");
        }