Move doStatsForFlushing function

Change-Id: I5511363539d846680bdfd366e227084abcb61c1b