lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


What kind of test do you need?
Do you agree, that it is better to make assertion success case
as fast as your can, but assertion failure case may be a little
slower in price of success case?
If not then my proposal is not for you.

But If you do agree then here is the point:
-------------
assert (something, any_kind_of_function)
is just equal to
assert (something, any_kind_of_string)
in case of assertion success.

assert (something, any_kind_of_function)
is faster
assert (something, any_kind_of_string..error_num)
in case of assertion success.

assert (something, any_kind_of_function)
is faster
assert (something, any_kind_of_function ())
in case of assertion success.

assert (something, any_kind_of_function)
is faster or equal
assert (something, just_anything)
in case of assertion success.
-------------

And it's logic of the language (including VM). No need for testing or something.
So if we talk about improving execution speed of
assertion success case (possibly in price of success failure case),
we should use function in all cases but constant string (not even
concatenated of 2).

On Sun, Jun 26, 2011 at 11:43 AM, Lorenzo Donati
<lorenzodonatibz@interfree.it> wrote:
> On 25/06/2011 22.55, Rebel Neurofog wrote:
>>
>> Well, it just will make things slower.
>> I've applied the patch for me anyway.
>> But I think it may be added to official versions.
>>
>
> Please, don't get me wrong, I do think the enhancement is interesting from a
> pure syntactical point of view.
>
> The problem I see is that your patch adds some weight to Lua for a speed
> gain which maybe is questionable (have you tested the speed enhancement
> against a pure Lua solution?).
>
> Moreover, you would have a substantial speed gain only if "assert" execution
> time (in the no-errror case) is comparable to the overall execution time of
> the whole function it is placed in.
>
> Of course you must have tested it in your code, so this patch is convenient
> for your situation.
>
> As for including it in Lua's codebase, I suspect that Lua team needs to be
> convinced with more profiling data on the general case before adding weight
> to Lua.
>
> Cheers.
> -- Lorenzo
>
>