Changeset 2


Ignore:
Timestamp:
Jul 22, 2015, 4:28:36 PM (9 years ago)
Author:
chronos
Message:

Show new line time when new characters are printed on that line.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/linetime.lpi

    r1 r2  
    3434        <Filename Value="linetime.lpr"/>
    3535        <IsPartOfProject Value="True"/>
    36         <UnitName Value="linetime"/>
    3736      </Unit0>
    3837    </Units>
  • trunk/linetime.lpr

    r1 r2  
    2222    StartTime: TDateTime;
    2323    NewLine: Boolean;
     24    ShowTime: Boolean;
    2425    LastLineTime: TDateTime;
    2526    procedure PrintOutput(Output: string);
     
    6364
    6465  NewLine := True;
     66  ShowTime := True;
    6567  FirstLine := True;
    6668  StartTime := Now;
     
    9193  LineTime: TDateTime;
    9294begin
    93   if (Length(Output) > 0) and NewLine then begin
     95  if NewLine then begin
     96    if FormatCSV then begin
     97      if not FirstLine then WriteLn('"');
     98    end else begin
     99      if not FirstLine then WriteLn('');
     100    end;
     101    NewLine := False;
     102    FirstLine := False;
     103  end;
     104  if (Length(Output) > 0) and ShowTime then begin
    94105    LineTime := Now - StartTime;
    95106    if FormatCSV then begin
    96       if not FirstLine then WriteLn('"');
    97107      Write(FloatToStrF(LineTime / OneSecond, ffFixed, 10, 2) + ',' +
    98108        FloatToStrF((LineTime - LastLineTime) / OneSecond, ffFixed, 10, 2) + ',"');
    99109    end else begin
    100       if not FirstLine then WriteLn('');
    101110      Write(#$1b'[0;32m' + FloatToStrF(LineTime / OneSecond, ffFixed, 10, 2) + #$1b'[0m ');
    102111    end;
    103     NewLine := False;
    104     FirstLine := False;
     112    ShowTime := False;
    105113    LastLineTime := LineTime;
    106114  end;
     
    122130      Delete(Buffer, 1, P + Length(LineEnding) - 1);
    123131      NewLine := True;
     132      ShowTime := True;
    124133    end;
    125134  until P = 0;
Note: See TracChangeset for help on using the changeset viewer.