C#でStopwatchクラスを使用
// using System;
// Stopwatchクラス生成
var sw = new System.Diagnostics.Stopwatch();
//-----------------
// 計測開始
sw.Start();
// ★処理A
// 計測停止
sw.Stop();
// 結果表示
Console.WriteLine("■処理Aにかかった時間");
TimeSpan ts = sw.Elapsed;
Console.WriteLine($" {ts}");
Console.WriteLine($" {ts.Hours}時間 {ts.Minutes}分 {ts.Seconds}秒 {ts.Milliseconds}ミリ秒");
Console.WriteLine($" {sw.ElapsedMilliseconds}ミリ秒");