[fpc-devel] Speed of TTestCase

Michael Van Canneyt michael at freepascal.org
Sun Jun 15 21:22:21 CEST 2025



On Sat, 14 Jun 2025, Martin Frb via fpc-devel wrote:

> On 14/06/2025 15:44, Michael Van Canneyt via fpc-devel wrote:
>>
>> I have heaps and heaps of testcases, but I've never felt the need to 
>> investigate
>> the speed of the Assert* calls.
>
> I wasn't actually looking at it... I found it by random chance.
>
> I was trying to kcachegrind some of my code, and the results said that 
> the majority of time went into string handling that wasn't part of the 
> tested code.
>
>
>>
>> Millions of AssertEquals calls ? I'm surprised that you are surprised 
>> it takes so long? :-)
> I haven't counted them.
>
> But some of my tests are simply fuzzing (ish) tests (not necessarily 
> random, but just throwing large amount of data at the code).
>
>>
>> If you present a patch to avoid constructing the message in case the 
>> test is
>> OK, that's certainly fine for me.
>
> I may... Need to find some time.
>
> Also, what do you think about overloading AssertEquals (and the like) taking
> AssertEqual(
>   const AnFormatString: string;
>   const AFormatData: array of const;
>   AnExpect,
>   AnActual: TFoo
> )
> ?

OK with me.

I would not do the checkequal since that will lead to confusion
with the Delphi DUnit compatibility layer.

Michael.


More information about the fpc-devel mailing list