<commit_before>//- Copyright  2008-2009 8th Light, Inc. All Rights Reserved.
//- Limelight and all included source files are distributed under terms of the GNU LGPL.

package limelight.util;

import junit.framework.TestCase;

public class NanoTimerTest extends TestCase
{
  private final int ONE_MILLION = 1000000;
  private final int TEN_MILLION = 10 * ONE_MILLION;
  private final int NINE_MILLION = 9 * ONE_MILLION;
  private final int ELEVEN_MILLION = 11 * ONE_MILLION;

  private NanoTimer timer;

  public void setUp() throws Exception
  {
    timer = new NanoTimer();
  }
  
  public void testStartTime() throws Exception
  {
    long now = System.nanoTime();
    long then = timer.getTimeOfLastActivity();
    assertEquals("" + (now - then), true, now - then < ONE_MILLION); // less than 1 milisecond
  }

  public void testIdleTime() throws Exception
  {
    assertEquals(true, timer.getIdleNanos() < ONE_MILLION);
    Thread.sleep(10);
    assertEquals(true, timer.getIdleNanos() > TEN_MILLION);
  }

  public void testSleeping()
  {
    long before = System.nanoTime();
    timer.sleep(TEN_MILLION);
    long after = System.nanoTime();
    long sleepDuration = after - before;

    assertEquals("actual sleep duration: " + sleepDuration, true, (sleepDuration > NINE_MILLION && sleepDuration < ELEVEN_MILLION));
    assertEquals(true, timer.getActualSleepDuration() > NINE_MILLION && timer.getActualSleepDuration() < ELEVEN_MILLION);
    assertEquals(true, timer.getIdleNanos() < ONE_MILLION);
    assertEquals(true, timer.getSleepJiggle() < ONE_MILLION);
  }

  public void testSleepDurationAndJiggle() throws Exception
  {
    for(int i = 0; i < 10; i++)
    {
      long before = System.nanoTime();
      timer.sleep(TEN_MILLION);<commit_msg>Trying to get build passing 21<commit_after>//- Copyright  2008-2009 8th Light, Inc. All Rights Reserved.
//- Limelight and all included source files are distributed under terms of the GNU LGPL.

package limelight.util;

import junit.framework.TestCase;

public class NanoTimerTest extends TestCase
{
  private final int ONE_MILLION = 1000000;
  private final int TEN_MILLION = 10 * ONE_MILLION;
  private final int NINE_MILLION = 9 * ONE_MILLION;
  private final int ELEVEN_MILLION = 11 * ONE_MILLION;
  private final int TWENTY_MILLION = 20 * ONE_MILLION;

  private NanoTimer timer;

  public void setUp() throws Exception
  {
    timer = new NanoTimer();
  }
  
  public void testStartTime() throws Exception
  {
    long now = System.nanoTime();
    long then = timer.getTimeOfLastActivity();
    assertEquals("" + (now - then), true, now - then < ONE_MILLION); // less than 1 milisecond
  }

  public void testIdleTime() throws Exception
  {
    assertEquals(true, timer.getIdleNanos() < ONE_MILLION);
    Thread.sleep(10);
    assertEquals(true, timer.getIdleNanos() > TEN_MILLION);
  }

  public void testSleeping()
  {
    long before = System.nanoTime();
    timer.sleep(TEN_MILLION);
    long after = System.nanoTime();
    long sleepDuration = after - before;

    assertEquals("actual sleep duration: " + sleepDuration, true, (sleepDuration > NINE_MILLION && sleepDuration < TWENTY_MILLION));
    assertEquals(true, timer.getActualSleepDuration() > NINE_MILLION && timer.getActualSleepDuration() < ELEVEN_MILLION);
    assertEquals(true, timer.getIdleNanos() < ONE_MILLION);
    assertEquals(true, timer.getSleepJiggle() < ONE_MILLION);
  }

  public void testSleepDurationAndJiggle() throws Exception
  {
    for(int i = 0; i < 10; i++)
    {
      long before = System.nanoTime();
      timer.sleep(TEN_MILLION);
{'fraction_non_alphanumeric': 0.10134003350083752, 'fraction_numerical': 0.01619207146845338, 'mean_word_length': 3.908219178082192, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 9, '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': '5613260', 'n_tokens_mistral': 1221, 'n_tokens_neox': 1139, 'n_words': 308}