Analysis of bunching of an electron beam at optical wavelengths