[Java]
long AverageTime =0; // declare a Average Time variable
long StartTime = System.currentTimeMillis(); // catch Timer currently
// ==============================
// Program
// ==============================
long ProcessTime = System.currentTimeMillis() - StartTime; // count timer
AverageTime += ProcessTime; // accumulate to add timer
//-----------------------------------------------------------------------
[Visual Studio C#]
System.Diagnostics;
/*
...
*/
Stopwatch space = new Stopwatch(); //new object space
space.Reset(); //reset timer
space = Stopwatch.StartNew(); //start timer
// ==============================
// Program
// ==============================
space.Stop(); //stop timer
/****show time methods****/
TimeSpan timer = space.Elapsed; //get time for seconds
//Console.WriteLine("時間 {0} 秒", timer); //print result in output list
long msecond = space.ElapsedMilliseconds; //get time for milliseconds
//Console.WriteLine("時間 {0} 毫秒", msecond);
TimerList.Text = timer + " seconds\t" + msecond + " milliseconds"; //show timer