Selection and population demography shape evolution of two long-lived ectotherms