andrestudio писал(а):
https://forum.hiasm.com/topic/63405Спасибо за компонент!!!
Я пытаюсь сделать тест скорости флешек и вроде получилось переделать компонент BenchmarkHDD
Add(MainForm,2953706,175,98)
{
Width=355
Height=246
Caption="Тест скорости накопителя"
Position=1
}
Add(Button,10465805,175,210)
{
Left=20
Top=170
Width=115
TabOrder=-1
Caption="Тестировать"
link(onClick,9133256:doEvent1,[])
}
Add(Edit,8931485,560,245)
{
Left=20
Top=95
Width=235
Text="Чтение..."
ReadOnly=0
}
Add(FormatStr,366920,504,245)
{
Mask="Скорость чтение: %1 MB/s"
link(onFString,8931485:doText,[])
}
Add(Thread,4660684,308,210)
{
Delay=0
FastStop=0
link(onExec,6057204:DoTest,[])
}
Add(InlineCode,6057204,364,210)
{
WorkPoints=#30:DoTest=Тестирование накопителя|
EventPoints=#27:WriteResult=Скорость записи|26:ReadResult=Скорость чтения|
VarPoints=#24:ProgressWrite=Ход записи|23:ProgressRead=Ход чтения|
DataPoints=#19:DiskHDD=Буква диска|38:SizeTest=Размер файла для тестирования|
Code=#15:unit HiAsmUnit;|0:|9:interface|0:|29:uses Windows,Kol,Share,Debug;|0:|4:type|31: THiAsmClass = class(TDebug) |3: |10: private|21: ProgressW:integer;|21: ProgressR:integer;|3: |9: public|21: DiskHDD:THI_Event;|22: SizeTest:THI_Event;|25: WriteResult:THI_Event;|24: ReadResult:THI_Event;|0:|49: procedure DoTest(var _Data:TData; Index:word);|55: procedure ProgressWrite(var Data:TData; Index:word);|54: procedure ProgressRead(var Data:TData; Index:word);|3: |5: end;|0:|14:implementation|0:|29:procedure THiAsmClass.DoTest;|4:var |19: i,size:integer;|32: timeStart,endTime,tmp:int64;|18: f,disk:string;|16: blk:pointer;|22: h,rd,flg:cardinal;|16: Result:real;|5:begin|14: Result := 0;|34: disk :=(ToStringEvent(DiskHDD));|36: size :=(ToIntegerEvent(SizeTest));|25: GetMem(blk, 1024*1024);|40: f := disk + ':\Test_Flash_Drive.tfd'; |133: h := CreateFile(PChar(f), GENERIC_WRITE, FILE_SHARE_WRITE, nil, CREATE_ALWAYS, FILE_FLAG_NO_BUFFERING or FILE_ATTRIBUTE_NORMAL, 0);|37: QueryPerformanceCounter(timeStart);|23: for i := 1 to size do|9: begin|40: WriteFile(h, blk^, 1024*1024, rd, nil);|15: ProgressW :=i;|5: end;|31: QueryPerformanceCounter(tmp);|17: CloseHandle(h);|0:|29: endTime := tmp - timeStart;|34: QueryPerformanceFrequency(tmp); |15: FreeMem(blk);|31: Result := size/(endTime/tmp);|34: _hi_OnEvent(WriteResult,Result);|0:|14: Result := 0;|25: GetMem(blk, 1024*1024);|39: f := disk + ':\Test_Flash_Drive.tfd';|136: h := CreateFile(PChar(f), GENERIC_READ, FILE_SHARE_READ, nil, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING or FILE_ATTRIBUTE_READONLY, 0); |37: QueryPerformanceCounter(timeStart);|23: for i := 1 to size do|9: begin|44: ReadFile(h, blk^, 1024*1024, rd, nil); |18: ProgressR :=i;|8: end;|31: QueryPerformanceCounter(tmp);|17: CloseHandle(h);|2: |29: endTime := tmp - timeStart;|33: QueryPerformanceFrequency(tmp);|24: DeleteFile(PChar(f)); |15: FreeMem(blk);|31: Result := size/(endTime/tmp);|33: _hi_OnEvent(ReadResult,Result);|0:|4:end;|0:|36:procedure THiAsmClass.ProgressWrite;|0:|5:begin|29: dtInteger(Data, ProgressW);|4:end;|0:|35:procedure THiAsmClass.ProgressRead;|0:|5:begin|29: dtInteger(Data, ProgressR);|4:end;|0:|4:end.|
link(WriteResult,450976:doConvert,[(422,216)(422,195)])
link(ReadResult,10556422:doConvert,[(422,223)(422,251)])
link(DiskHDD,4112081:Text,[])
link(SizeTest,7168988:Text,[])
}
Add(VisualStrings,4112081,364,140)
{
Lines=#1:H|
Width=53
}
Add(Edit,2964571,560,189)
{
Left=20
Top=20
Width=235
Text="Запись..."
ReadOnly=0
}
Add(ConvertorEx,450976,448,189)
{
Mode=15
link(onResult,1619973:doString,[])
}
Add(VisualStrings,7168988,371,161)
{
Lines=#4:1024|
Width=53
}
Add(Timer,13206254,273,301)
{
Enable=1
link(onTimer,2738849:doEvent1,[])
}
Add(ProgressBar,10458950,420,301)
{
Left=20
Top=55
Width=300
Max=1024
}
Add(FormatStr,1619973,504,189)
{
Mask="Скорость записи: %1 MB/s"
link(onFString,2964571:doText,[])
}
Add(StyleXP,8000213,175,154)
{
}
Add(Edit,7978056,364,301)
{
Left=270
Top=20
Text=""
ReadOnly=0
link(onChange,10458950:doPosition,[])
link(Str,6057204:ProgressWrite,[])
}
Add(ConvertorEx,10556422,448,245)
{
Mode=15
link(onResult,366920:doString,[])
}
Add(Hub,2738849,322,301)
{
link(onEvent1,7978056:doText,[])
link(onEvent2,14224937:doText,[(350,314)(350,349)])
}
Add(Edit,14224937,371,343)
{
Left=270
Top=95
Text=""
ReadOnly=0
link(onChange,14922194:doPosition,[])
link(Str,6057204:ProgressRead,[])
}
Add(ProgressBar,14922194,427,343)
{
Left=20
Top=130
Width=300
Max=1024
}
Add(Hub,9133256,224,210)
{
link(onEvent1,4660684:doStart,[])
link(onEvent2,13206254:doTimer,[(256,223)(256,307)])
}
Остался 1 нерешенный вопрос. Как сделать остановку цикла в InlineCode по нажатию кнопки?