Tradeoff between energy and error in the discrimination of quantum-optical devices