redding / assert

Assertion style testing framework.
https://github.com/redding/assert
MIT License
10 stars 1 forks source link

optimize fail msg handling #147

Closed kellyredding closed 10 years ago

kellyredding commented 10 years ago

No need to create all these fail msg strings if the assert passes. This moves the custom "what failed" message definition to a block. The block is only yielded to if the assertion fails.

This also reworks the processing of fail messages to not work in Procs but instead just take arbitrary string args and join them with new lines.

The added overhead of creating a block for every what failed message should be negated by removing the overhead of creating a proc for processing every fail message that we were already doing.

@jcredding ready for review. Not this has a few "breaking" changes:

jcredding commented 10 years ago

@kellyredding - Curiously, you might test how it performs if you have no procs and just use strings. It's kinda testing whether ruby is more efficient at making strings or procs.

jcredding commented 10 years ago

@kellyredding - This looks more efficient than the previous method of handling fail messages. If the procs are more efficient than the strings, I'm good with this :boom:

kellyredding commented 10 years ago

@jcredding thanks for the suggestion of testing with strings - I switched to creating string instead of procs. The procs seem to be more efficient.

With strings:

3115 results: all pass

(13.507749 seconds)

With procs:

3115 results: all pass

(11.885248 seconds)

I'm going to go with this proc approach.