home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2002 September
/
Chip_2002-09_cd1.bin
/
zkuste
/
delphi
/
kompon
/
d6
/
YPPARSER.ZIP
/
SpeedTest
/
MainForm.pas
< prev
next >
Wrap
Pascal/Delphi Source File
|
2002-06-14
|
8KB
|
220 lines
{********************************************************}
{ }
{ SpeedTest }
{ IMPORTANT-READ CAREFULLY: }
{ }
{ This End-User License Agreement is a legal }
{ agreement between you (either an individual }
{ or a single entity) and Pisarev Yuriy for }
{ the software product identified above, which }
{ includes computer software and may include }
{ associated media, printed materials, and "online" }
{ or electronic documentation ("SOFTWARE PRODUCT"). }
{ By installing, copying, or otherwise using the }
{ SOFTWARE PRODUCT, you agree to be bound by the }
{ terms of this LICENSE AGREEMENT. }
{ }
{ If you do not agree to the terms of this }
{ LICENSE AGREEMENT, do not install or use }
{ the SOFTWARE PRODUCT. }
{ }
{ License conditions }
{ }
{ No part of the software or the manual may be }
{ multiplied, disseminated or processed in any }
{ way without the written consent of Pisarev }
{ Yuriy. Violations of these conditions will be }
{ prosecuted in every case. }
{ }
{ The use of the software is done at your own }
{ risk. The manufacturer and developer accepts }
{ no liability for any damages, either as direct }
{ or indirect consequence of the use of this }
{ product or software. }
{ }
{ Only observance of these conditions allows you }
{ to use the hardware and software in your computer }
{ system. }
{ }
{ All rights reserved. }
{ Copyright 2002 Pisarev Yuriy }
{ }
{ yuriy_mbox@hotmail.com }
{ }
{********************************************************}
unit MainForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, DataEditor, ComCtrls, Menus, ActnList, ActnMan,
ImgList, StdActns;
type
TMain = class(TForm)
gbNumScript: TGroupBox;
NumScriptBtn: TButton;
StatusBar: TStatusBar;
gbBoolScript: TGroupBox;
BoolScriptBtn: TButton;
gbRepeatCount: TGroupBox;
TrackBar: TTrackBar;
reNumScript: TRichEdit;
reBoolScript: TRichEdit;
ActionManager1: TActionManager;
PopupMenu1: TPopupMenu;
ImageList1: TImageList;
RichEdit: TRichEdit;
laScriptView: TLabel;
EditCut: TEditCut;
EditCopy: TEditCopy;
EditPaste: TEditPaste;
EditSelectAll: TEditSelectAll;
EditUndo: TEditUndo;
EditDelete: TEditDelete;
Undo1: TMenuItem;
N1: TMenuItem;
Cut1: TMenuItem;
Copy1: TMenuItem;
Paste1: TMenuItem;
Delete1: TMenuItem;
N2: TMenuItem;
SelectAll1: TMenuItem;
procedure NumScriptBtnClick(Sender: TObject);
procedure BoolScriptBtnClick(Sender: TObject);
procedure TrackBarChange(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure reNumScriptKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
procedure reBoolScriptKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
FRepeatCount: Integer;
FDataEditor: TDataEditor;
public
procedure Status(ScriptID: Integer; Script: TScript;
TickCount, Result: Double);
property DataEditor: TDataEditor read FDataEditor write FDataEditor;
property RepeatCount: Integer read FRepeatCount write FRepeatCount;
end;
var
Main: TMain;
implementation
{$R *.dfm}
procedure TMain.FormCreate(Sender: TObject);
begin
FDataEditor := TDataEditor.Create(Self);
with FDataEditor.AttrsManager do begin
Add(reNumScript);
Add(reBoolScript);
end;
TrackBarChange(nil);
end;
procedure TMain.NumScriptBtnClick(Sender: TObject);
var
I: Integer;
TickCount: Double;
begin
Screen.Cursor := crHourGlass;
try
with FDataEditor do begin
StringToNumScript(reNumScript.Text);
with RichEdit.Lines do begin
Clear;
Add(Format('Text: "%s"; script length: %d',
[reNumScript.Text, Length(Script)]));
end;
TickCount := GetTickCount;
for I := 1 to FRepeatCount do ExecuteNum;
TickCount := GetTickCount - TickCount;
Status(NumScriptID, Script, TickCount, ExecuteNum);
end;
finally
Screen.Cursor := crDefault;
end;
end;
procedure TMain.reNumScriptKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_RETURN then NumScriptBtnClick(nil);
end;
procedure TMain.BoolScriptBtnClick(Sender: TObject);
var
I: Integer;
TickCount: Double;
begin
Screen.Cursor := crHourGlass;
try
with FDataEditor do begin
StringToBoolScript(reBoolScript.Text);
with RichEdit.Lines do begin
Clear;
Add(Format('Text: "%s"; script length: %d',
[reBoolScript.Text, Length(Script)]));
end;
TickCount := GetTickCount;
for I := 1 to FRepeatCount do ExecuteBool;
TickCount := GetTickCount - TickCount;
Status(BoolScriptID, Script, TickCount, Integer(ExecuteBool));
end;
finally
Screen.Cursor := crDefault;
end;
end;
procedure TMain.reBoolScriptKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if Key = VK_RETURN then BoolScriptBtnClick(nil);
end;
procedure TMain.Status(ScriptID: Integer; Script: TScript; TickCount, Result: Double);
var
I: Integer;
Value, Separator: string;
begin
Value := '';
for I := Low(Script) to High(Script) do begin
if I mod 4 = 0 then Separator := '___' else Separator := '_';
if I = Low(Script) then Value := IntToStr(Script[I])
else Value := Value + Separator + IntToStr(Script[I]);
end;
with RichEdit.Lines do begin
Add('');
Add('Script as array of 1-byte integer numbers: ' + Value);
end;
Value := '';
I := 0;
while I < Length(Script) do begin
if I = Low(Script) then Value := IntToStr(PInteger(@Script[I])^)
else Value := Value + '_' + IntToStr(PInteger(@Script[I])^);
Inc(I, IntegerSize);
end;
with RichEdit.Lines do begin
Add('');
Add('Script as array of 4-byte integer numbers: ' + Value);
end;
if ScriptID = NumScriptID then StatusBar.Panels[1].Text := Format('Result: %f', [Result])
else if Result = 0 then StatusBar.Panels[1].Text := 'Result: False'
else StatusBar.Panels[1].Text := 'Result: True';
StatusBar.Panels[2].Text := Format('Execution time: %d sec %d msec',
[Trunc(TickCount / 1000), Trunc(TickCount - Trunc(TickCount / 1000) * 1000)]);
end;
procedure TMain.TrackBarChange(Sender: TObject);
begin
FRepeatCount := TrackBar.Position * 100000;
StatusBar.Panels[0].Text := Format('Operations amount: %d', [FRepeatCount]);
end;
end.