Add condition to set profiling ratio and set writer at flush