chromium/tools/perf/page_sets/tough_canvas_cases/rendering_throughput/bench.js

// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

var bench = (function() {
  var rafFunc;
  var drawFunc;

  function tick() {
    drawFunc();
    rafFunc(tick);
  };

  function startAnimation() {
    rafFunc = window.requestAnimationFrame ||
              window.webkitRequestAnimationFrame ||
              window.mozRequestAnimationFrame ||
              window.oRequestAnimationFrame ||
              window.msRequestAnimationFrame;
    rafFunc(tick);
  };

  var bench = {};
  bench.run = function(df) {
    drawFunc = df;
    startAnimation();
  };
  return bench;
})();