1. An optical apparatus for performing inspection or metrology of a semiconductor device, comprising: a plurality of laser diode arrays that are configurable to provide an incident beam having different wavelength ranges; optics for directing the incident beam towards the sample; a detector for generating an output signal or image based on an output beam emanating from the sample in response to the incident beam; optics for directing the output beam towards the detector; and a controller for configuring the laser diode arrays to provide the incident beam at the different wavelength ranges and detecting defects or characterizing a feature of the sample based on the output signal or image, wherein the controller is configured to activate one or more laser diode arrays so that the incident beam has a specific wavelength range that is selected from the different wavelength ranges and configured to deactivate other one or more of the laser diode arrays so that the incident beam does not include any wavelengths that are not within the specific wavelength range.