Newer
Older
TIASshot / TIASshot / UI / TimedPictureBox.cs
#if MEMMONITOR
using System.Diagnostics;
using System.Windows.Forms;

namespace TIASshot {

    /// <summary>
    /// 副モニタの実描画時間を計測する PictureBox(MEMMONITOR 限定)。
    /// base.OnPaint(実際の GDI 描画)の所要時間を PreviewProfiler に記録し,
    /// 「副モニタの描画コストそのものが増えているか」を sub_paint_ms として可視化する。
    /// 本番ビルドでは本クラスごとコンパイルされないため,通常の PictureBox と挙動は一切変わらない。
    /// </summary>
    internal class TimedPictureBox : PictureBox {
        protected override void OnPaint(PaintEventArgs pe) {
            long t0 = Stopwatch.GetTimestamp();
            base.OnPaint(pe);
            PreviewProfiler.AddSubPaintTicks(Stopwatch.GetTimestamp() - t0);
        }
    }
}
#endif