<commit_before>/*
 * (c) 2009 <NAME>.
 */

package org.rlcommunity.critter;

/** The clock part of the SimulatorScheduler. Keeps track of how fast the
 *   system is running compared to how fast it should run.
 *
 * @author <NAME> (mg17 at cs ualberta ca)
 */
public class SimulatorSchedulerClock {
    public final int NANOSECONDS_IN_MILLISECOND = 1000000;

    protected long aStartNanos;
    protected double tau;
    protected double averageTime;
    protected long count;
    protected boolean isBehindFlag;
    
    public SimulatorSchedulerClock() {
      tau = 0;
    }

    public boolean isBehind() { return isBehindFlag; }

    public void startClock() {
      startClock(System.nanoTime());
    }
    
    public void startClock(long pNanos) {
      aStartNanos = pNanos;
    }

    public long endClock(double pDelta) {
      return endClock(pDelta, System.nanoTime());
    }

    public long endClock(double pDelta, long pNanos) {
      long computationTime = pNanos - aStartNanos;

      averageTime += computationTime;
      count++;
      tau += pDelta - (1.0 * computationTime) / NANOSECONDS_IN_MILLISECOND;

      long fullMillis;
<commit_msg>Added some comments to the scheduler clock<commit_after>/*
 * (c) 2009 <NAME>.
 */

package org.rlcommunity.critter;

/** The clock part of the SimulatorScheduler. Keeps track of how fast the
 *   system is running compared to how fast it should run.
 *
 * @author <NAME> (mg17 at cs ualberta ca)
 */
public class SimulatorSchedulerClock {
    public final int NANOSECONDS_IN_MILLISECOND = 1000000;

    protected long aStartNanos;
    protected double tau;
    protected double averageTime;
    protected long count;
    protected boolean isBehindFlag;
    
    public SimulatorSchedulerClock() {
      tau = 0;
    }

    public boolean isBehind() { return isBehindFlag; }

    /** Tells the clock to start counting how long a given operation takes.
     * 
     */
    public void startClock() {
      startClock(System.nanoTime());
    }
    
    public void startClock(long pNanos) {
      aStartNanos = pNanos;
    }

    /** Tells the clock to stop ticking.
     *
     * @param pDelta The desired number of milliseconds for the clocked
     *  operation.
     * @return The actual number of milliseconds we should sleep.
     */
    public long endClock(double pDelta) {
      return endClock(pDelta, System.nanoTime());
    }

    public long endClock(double pDelta, long pNanos) {
      long computationTime = pNanos - aStartNanos;

      averageTime += computationTime;
      count++;
      tau += pDelta - (1.0 * computationTime) / NANOSECONDS_IN_MILLISECOND;

      long fullMillis;

{'fraction_non_alphanumeric': 0.08314522197140707, 'fraction_numerical': 0.012039127163280662, 'mean_word_length': 2.836940836940837, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '979284', 'n_tokens_mistral': 846, 'n_tokens_neox': 792, 'n_words': 252}