Adds timer API

Patch for #1073.