The intensity of Smith-Purcell radiation from metallic and dielectric gratings (silicon, silica) is compared in a frequency-domain simulation. The numerical model is discussed and verified with the Frank-Tamm formula for Cherenkov radiation. For 30 keV electrons, rectangular dielectric gratings are less efficient than their metallic counterpart, by an order of magnitude for silicon, and two orders of magnitude for silica. For all gratings studied, radiation intensity oscillates with grating tooth height due to electromagnetic resonances in the grating. 3D and 2D numerical models are compared.