How to remove System.out.println's from codebase

前端 未结 8 1422
天涯浪人
天涯浪人 2020-12-15 11:26

We have a huge (old legacy java) code-base, where many files (around 5k) have System.out.println\'s. We are planning to remove them for cleanup/performance reasons. How can

8条回答
  •  旧巷少年郎
    2020-12-15 11:52

    You could start by calling Systems.setOut and passing in your own OutputStream that does nothing. That will help you see if there is a perfomance gain. This is safer than removing them (for the reason that Oscar pointed out - coding by side effect). If the performance gain is negligable then you might want to focus your efforts elsewhere.

    Two issues with my above method:

    1. any System.out.printlns you want to keep will disapper too
    2. the String concatination will still take place (and that can be expensive depending on how much there is)

    However it is a good quick test to see if you get the performance gains you are looking for.

提交回复
热议问题