<commit_before>import Ember from 'ember';

/**
 * If the performance API is missing, polyfill using Date
 */
if (!window.performance || !window.performance.now) {
  window.performance = window.performance || {};
  window.performance.now = function () {
    return (new Date()).getTime();
  };
}


export default Ember.Service.extend({
  /**
   * Initialize the TransitionData object that holds information about a transition
   * @type {Object}
   */
  currentTransition: {
    isInitial: true,
    start: 0,
    startTimestamp: window.performance.timing ? window.performance.timing.navigationStart : (new Date()).getTime()
  },
  /**
   * Create a new object that contains the start timstamp in milliseconds and start attribute using
   * window.performance.now. It is assumed that once this function is called, it is a subsequent transition
   * Store the new object in the service
   */
  startTransition: function () {
    var newTransitionData = {
      isInitial: false,
      start: window.performance.now(),
      startTimestamp: (new Date()).getTime()
    };
    this.set('currentTransition', newTransitionData);
  },
  /**
   * Store the destination route and pathname with the end timer.
   *
   * @param  {String} finalRouteName Destination route name
   * @param  {String} finalPathName  Destination pathname expected to be from this.get('router.url') from a route
   * @return {null}                  Returns nothing
   */
  endTransition: function (finalRouteName, finalPathName) {
    var transitionData = this.get('currentTransition');
    transitionData.end = window.performance.now();<commit_msg>usign performance.now()<commit_after>import Ember from 'ember';

/**
 * If the performance API is missing, polyfill using Date
 */
var navigationStart = 0;
var performanceNow = function() {
  if ('performance' in window && typeof window.performance.now === 'function' && typeof fastboot === 'undefined') {
    return window.performance.now();
  } else {
    return (new Date).getTime() - navigationStart;
  }
};
navigationStart = window.performance.timing ? window.performance.timing.navigationStart : performanceNow();

export default Ember.Service.extend({
  /**
   * Initialize the TransitionData object that holds information about a transition
   * @type {Object}
   */
  currentTransition: {
    isInitial: true,
    start: 0,
    startTimestamp: navigationStart
  },
  /**
   * Create a new object that contains the start timstamp in milliseconds and start attribute using
   * window.performance.now. It is assumed that once this function is called, it is a subsequent transition
   * Store the new object in the service
   */
  startTransition: function () {
    var newTransitionData = {
      isInitial: false,
      start: performanceNow(),
      startTimestamp: navigationStart + performanceNow()
    };
    this.set('currentTransition', newTransitionData);
  },
  /**
   * Store the destination route and pathname with the end timer.
   *
   * @param  {String} finalRouteName Destination route name
   * @param  {String} finalPathName  Destination pathname expected to be from this.get('router.url') from a route
   * @return {null}                  Returns nothing
   */
  endTransition: function (finalRouteName, finalPathName) {
    var transitionData = this.get('currentTransition');
    transitionData.end = window.performance.now();
{'fraction_non_alphanumeric': 0.10484110484110484, 'fraction_numerical': 0.000891000891000891, 'mean_word_length': 3.569877883310719, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2962498', 'n_tokens_mistral': 903, 'n_tokens_neox': 875, 'n_words': 294}