Performance Analysis and Optimization of a Robust Algorithm for Voltage Transients Detection