benchmark
benchmark copied to clipboard
VCL
Don't work in VCL
Is it too much to ask for more details?
Sure, why not?
I do the same example on the benchmark page, but a get error.
E2009 Incompatible types: 'regular procedure and method pointer'
After a while I managed to run the example.
Actually it was because I needed a user class procedure, not a simple procedure or function.
class procedure TForm3.BM_SomeFunction(const state: TState);
begin
// Perform setup here
for var _ in state do
begin
GetTest;
end;
end;
procedure TForm3.Button1Click(Sender: TObject);
begin
// Register the function as a benchmark
Benchmark(BM_SomeFunction, 'GetTest');
// Run the benchmark
Benchmark_Main;
end;
class procedure TForm3.GetTest;
begin
sleep(2000);
end;
But, yet a have erro
It could have examples, it would be good. :)
- The benchmark function has to be a
procedure(const state: TState)
you are providing a method - they are incompatible. This has nothing to do with VCL. You might want to read up on them in the documentation - The IO error is a result of calling
Write
from a VCL application
Benchmark is meant to run as a console application - there is no point on running this inside a VCL application.