The period function and the harmonic balance method