zoukankan      html  css  js  c++  java
  • Handbook之011:TStopWatch计时类

    很好用的一个计时类,用于计算某个功能耗时的毫秒数量

    image

    unit Unit1;
    
    interface
    
    uses
      Winapi.Windows,
      Winapi.Messages,
      System.SysUtils,
      System.Variants,
      System.Classes,
      Vcl.Graphics,
      Vcl.Controls,
      Vcl.Forms,
      Vcl.Dialogs,
      Vcl.StdCtrls;
    
    type
      TForm1 = class(TForm)
        Memo1: TMemo;
        Button1: TButton;
        procedure Button1Click(Sender: TObject);
      private
        { Private declarations }
      public
        { Public declarations }
      end;
    
    var
      Form1: TForm1;
    
    
    implementation
    
    {$R *.dfm}
    uses
      System.Diagnostics,
      System.Math;
    
    //函数定义
    procedure ShowOnMemo(ACount: Integer);
    var
      m_Watch: TStopwatch;
      I, J: Integer;
    begin
      J := 0;
      m_Watch := TStopWatch.StartNew;
      for I := 0 to ACount do
      begin
        J := Max(I, J);
      end;
      m_Watch.Stop;
      Form1.Memo1.Lines.Add('循环总耗时: ' + m_Watch.ElapsedMilliseconds.ToString);
    end;
    
    //计时
    procedure TForm1.Button1Click(Sender: TObject);
    begin
      ShowOnMemo(2000000);
    end;
    
    end.
  • 相关阅读:
    POJ 3093 Margaritas on the River Walk(背包)
    BZOJ 2287 【POJ Challenge】消失之物(DP+容斥)
    WC2017 Day1
    WC2017 Day0
    WC2017 Conclusion
    WC2017 Day6
    UOJ #58 糖果公园
    WC2017 Day5
    codevs 1946 阿狸的打字机
    HDU 2457 DNA_repair
  • 原文地址:https://www.cnblogs.com/GodPan/p/4908095.html
Copyright © 2011-2022 走看看