This paper proposes an algorithm for testing portfolio efficiency with respect to FSD optimality criterion. Using properties of representative set of utility functions for FSD optimality relation, a necessary and sufficient condition for FSD optimality is derived.