1

as i know assertions are been used to assert any value. But if i add, large number of assertion code to my project, it that affect my performance?

Ant's
  • 13,545
  • 27
  • 98
  • 148
  • Do you mean that you are adding assertions in production code? – Vinod R Mar 05 '11 at 12:05
  • No i'm still an student, just what to know whether these assertion increase the line of code and affect in performance? – Ant's Mar 05 '11 at 12:10
  • See also http://stackoverflow.com/questions/8077757/is-groovys-assert-a-good-idea-for-production-code-unlike-javas-assert – ripper234 Nov 10 '11 at 10:57

1 Answers1

1

Yes, assertions do affect performance. Depending on the application, it might or might not matter. Anyway, assertions are primarily meant for cases where the performance overhead doesn't matter (tests, scripting). And if you add a custom message (assert x > 10, "x should be greater than 10"), the overhead will be smaller because the assertion's values won't be recorded.

Peter Niederwieser
  • 121,412
  • 21
  • 324
  • 259