<commit_before>package ilg.gnuarmeclipse.packs.data.jobs;

import ilg.gnuarmeclipse.packs.core.ConsoleStream;
import ilg.gnuarmeclipse.packs.data.Utils;

import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.MessageConsoleStream;

/**
 * Support for showing a Busy Cursor during a long running process.
 * <p>
 */
public class BusyIndicatorWithDuration {

	private static MessageConsoleStream sfOut = ConsoleStream.getConsoleOut();

	/**
	 * Display a time stamp, run the code and display the duration, in ms.
	 * 
	 * @param message
	 *            a string, or null.
	 * @param runnable
	 *            a class that implements run().
	 */
	public static void showWhile(Runnable runnable) {

		long beginTime = System.currentTimeMillis();

		sfOut.println();
		sfOut.println(Utils.getCurrentDateTime());

		BusyIndicator.showWhile(Display.getDefault(), runnable);

		long endTime = System.currentTimeMillis();
		long duration = endTime - beginTime;
		if (duration == 0) {
			duration = 1;
		}
		sfOut.print("Completed in ");
		sfOut.println(duration + "ms.");

	}
}<commit_msg>packs: busy indicator with depth counter<commit_after>package ilg.gnuarmeclipse.packs.data.jobs;

import ilg.gnuarmeclipse.packs.core.ConsoleStream;
import ilg.gnuarmeclipse.packs.data.Utils;

import org.eclipse.swt.custom.BusyIndicator;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.console.MessageConsoleStream;

/**
 * Support for showing a Busy Cursor during a long running process.
 * <p>
 */
public class BusyIndicatorWithDuration {

	private static int sfDepth = 0;
	private static MessageConsoleStream sfOut = ConsoleStream.getConsoleOut();

	/**
	 * Display a time stamp, run the code and display the duration, in ms.
	 * 
	 * @param message
	 *            a string, or null.
	 * @param runnable
	 *            a class that implements run().
	 */
	public static void showWhile(Runnable runnable) {

		sfDepth++;
		long beginTime = System.currentTimeMillis();

		if (sfDepth == 1) {
			sfOut.println();
			sfOut.println(Utils.getCurrentDateTime());
		}

		BusyIndicator.showWhile(Display.getDefault(), runnable);

		long endTime = System.currentTimeMillis();
		long duration = endTime - beginTime;
		if (duration == 0) {
			duration = 1;
		}
		sfOut.print("Completed in ");
		sfOut.println(duration + "ms.");

		sfDepth--;
	}
}
{'fraction_non_alphanumeric': 0.114321608040201, 'fraction_numerical': 0.002512562814070352, 'mean_word_length': 3.787575150300601, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1094813', 'n_tokens_mistral': 795, 'n_tokens_neox': 735, 'n_words': 187}