better cross-platform timing code