benchmark icon indicating copy to clipboard operation
benchmark copied to clipboard

VCL

Open BoscoBecker opened this issue 11 months ago • 1 comments

Don't work in VCL

BoscoBecker avatar Mar 17 '24 17:03 BoscoBecker

Is it too much to ask for more details?

sglienke avatar Mar 17 '24 17:03 sglienke

Sure, why not?

I do the same example on the benchmark page, but a get error.

image

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

image

It could have examples, it would be good. :)

BoscoBecker avatar Aug 28 '24 13:08 BoscoBecker

  • 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.

sglienke avatar Aug 29 '24 00:08 sglienke