title: Javascript - measuring FPS and sync it with events
body: <p>let's suppose I have a game loop like this</p>
  
  <pre><code>function update(){
  
  myTime = Date.now() - myTime
  
  // use myTime as you wish...
  
  
  // reset myTime
  myTime = Date.now()  
  
  }
  </code></pre>
  
  <p>stuff happens there, ideally at 60fps but not always. Using Date.now() I need to know how many milliseconds happens between one frame and the other. Here's why:</p>
  
  <p>I have a variable <code>X</code>, this variable should lineary increase so that every 1 second it is increased of 480 units. This increasing should be as smooth as possible so, I think, it should be of 0,48 every millisecond.</p>
  
  <p>How can I do that considering that I just draw to the screen every 16,6 milliseconds (60fps)? Do I need to compensate that by adding 0,48 * 16,6 ? Or... what kind of forumla? I'm getting crazy on this, thanks in advance!</p>