<commit_before>package org.mac.sim.simulation;

import java.util.List;
import java.util.concurrent.BlockingQueue;

import org.mac.sim.clock.Clock;
import org.mac.sim.clock.ClockManager;
import org.mac.sim.thread.WorkQueueManager;
import org.mac.sim.thread.Worker;
import org.mac.sim.thread.WorkerTask;

class QueueSimulationImpl implements Simulation {

	private ClockManager clockManager;
	private WorkQueueManager queueManager;
	private List<Worker> workers;
	private BlockingQueue<WorkerTask> taskQueue;

	/**
	 * Constructs required managers.
	 * 
	 * @param clock
	 * @param workers
	 * @param taskQueue
	 * @param ratePerPeriod
	 */
	QueueSimulationImpl(final Clock clock, final List<Worker> workers, final BlockingQueue<WorkerTask> taskQueue,
			final int ratePerPeriod) {

		// TODO must set proper sleep interval
		this.clockManager = new ClockManager(clock);
		this.workers = workers;
		this.taskQueue = taskQueue;
		this.queueManager = new WorkQueueManager(taskQueue, ratePerPeriod, clock);
	}

	/**
	 * Executes the simulation with the constructed clock manager, queue
	 * manager, and workers.
	 */
	public void execute() throws InterruptedException {

		// Start the queue manager
		queueManager.start();

		// Start each worker
		for (Worker worker : workers) {
			worker.start();
		}

		// Start the clock
		clockManager.start();

		// Wait for clockManager to complete
		clockManager.join();
		queueManager.join();

		// Stop the queueManager
		queueManager.doStop();

		// Stop each worker
		for (Worker worker : workers) {
			worker.doStop();
		}
	}

}
<commit_msg>added logic to track completed tasks and time spent in loop<commit_after>package org.mac.sim.simulation;

import java.util.List;
import java.util.concurrent.BlockingQueue;

import org.mac.sim.clock.Clock;
import org.mac.sim.clock.ClockManager;
import org.mac.sim.thread.WorkQueueManager;
import org.mac.sim.thread.Worker;
import org.mac.sim.thread.WorkerTask;

class QueueSimulationImpl implements Simulation {

	private ClockManager clockManager;
	private WorkQueueManager queueManager;
	private List<Worker> workers;
	private BlockingQueue<WorkerTask> taskQueue;

	/**
	 * Constructs required managers.
	 * 
	 * @param clock
	 * @param workers
	 * @param taskQueue
	 * @param ratePerPeriod
	 */
	QueueSimulationImpl(final Clock clock, final List<Worker> workers, final BlockingQueue<WorkerTask> taskQueue,
			final int ratePerPeriod) {

		// TODO must set proper sleep interval
		this.clockManager = new ClockManager(clock);
		this.workers = workers;
		this.taskQueue = taskQueue;
		this.queueManager = new WorkQueueManager(taskQueue, ratePerPeriod, clock);
	}

	/**
	 * Executes the simulation with the constructed clock manager, queue
	 * manager, and workers.
	 */
	public void execute() throws InterruptedException {

		// Start the queue manager
		queueManager.start();

		// Start each worker
		for (Worker worker : workers) {
			worker.start();
		}

		// Start the clock
		clockManager.start();

		// Wait for clockManager to complete
		clockManager.join();
		queueManager.join();

		// Stop each worker
		int totalTasksCompleted = 0;
		for (Worker worker : workers) {
			worker.doStop();
			totalTasksCompleted += worker.getTasksCompleted();
		}

		queueManager.getPeriodsSpentInLoop();
	}

}

{'fraction_non_alphanumeric': 0.099178582293885, 'fraction_numerical': 0.000304228780042592, 'mean_word_length': 4.105590062111801, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, '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': '4739078', 'n_tokens_mistral': 1039, 'n_tokens_neox': 935, 'n_words': 264}