Commit 3974db19 authored by Philip Makedonski's avatar Philip Makedonski
Browse files

+ fix for #1, add single-core processing option

parent 87cb0d37
Loading
Loading
Loading
Loading
+15 −0
Original line number Diff line number Diff line
@@ -44,6 +44,7 @@ public class T3Q {
	private boolean generateNewConfiguration = false;
	private boolean generateLocalDependencies = false;
	private final Stopwatch stopwatch = Stopwatch.createUnstarted();
	private boolean singleCore = false;
	
	// private boolean formattingEnabled = false;

@@ -108,6 +109,9 @@ public class T3Q {
		logger.setMaximumLogLevel(logLevel);
		TTCN3ResourceProvider resourceProvider = new TTCN3ResourceProvider(inputPaths, logger, activeProfile);
		TTCN3GlobalScopeProvider.LIVE = false;
		if (isSingleCore()) {
			resourceProvider.setCores(1);
		}
		resourceProvider.loadResources();
		//TODO: check if it has to be exclusive
		if (!this.isGenerateLocalDependencies()) {
@@ -198,6 +202,9 @@ public class T3Q {
		if (commandLine.hasOption("profile")) {
			this.setSelectedProfileName(commandLine.getOptionValue("profile"));
		}
		if (commandLine.hasOption("single-core")) {
			this.setSingleCore(true);
		}
		if (commandLine.hasOption("verbosity")) {
			this.selectLogLevel(commandLine.getOptionValue("verbosity"));
		}
@@ -424,4 +431,12 @@ public class T3Q {
	public void setGenerateLocalDependencies(boolean generateLocalDependencies) {
		this.generateLocalDependencies = generateLocalDependencies;
	}

	public boolean isSingleCore() {
		return singleCore;
	}

	public void setSingleCore(boolean singleCore) {
		this.singleCore = singleCore;
	}
}
+12 −4
Original line number Diff line number Diff line
@@ -52,7 +52,7 @@ public class TTCN3ResourceProvider {
	private ArrayList<String> paths;
	private LoggingInterface logger;
	private QualityCheckProfile activeProfile;
	private final int cores = Runtime.getRuntime().availableProcessors();
	private int cores = Runtime.getRuntime().availableProcessors();
	
	@Inject
	private IQualifiedNameProvider qualifiedNameProvider;
@@ -75,7 +75,7 @@ public class TTCN3ResourceProvider {
		
		stopwatch.start();
		
		ExecutorService pool = Executors.newFixedThreadPool(cores);
		ExecutorService pool = Executors.newFixedThreadPool(getCores());
		ArrayList<FileParser> parser = new ArrayList<FileParser>();
		
		for (String path : paths) {
@@ -130,7 +130,7 @@ public class TTCN3ResourceProvider {

	public void analyzeResources() {
		Stopwatch watchAnalyzing = Stopwatch.createStarted();
		ExecutorService pool = Executors.newFixedThreadPool(cores);
		ExecutorService pool = Executors.newFixedThreadPool(getCores());
		
		// Check if resource is a ignored one and if so, do not analyze it.
		Pattern pattern = Pattern.compile(activeProfile.getIgnoredResourceRegExp());
@@ -183,7 +183,7 @@ public class TTCN3ResourceProvider {

	public void analyzeDependencies() {
		Stopwatch watchAnalyzing = Stopwatch.createStarted();
		ExecutorService pool = Executors.newFixedThreadPool(cores);
		ExecutorService pool = Executors.newFixedThreadPool(getCores());
		
		// Check if resource is a ignored one and if so, do not analyze it.
		Pattern pattern = Pattern.compile(activeProfile.getIgnoredResourceRegExp());
@@ -386,4 +386,12 @@ public class TTCN3ResourceProvider {
			return res[0];
		}
	}

	public int getCores() {
		return cores;
	}

	public void setCores(int cores) {
		this.cores = cores;
	}
}
+4 −1
Original line number Diff line number Diff line
@@ -36,7 +36,7 @@ public class OptionsHandler {
		getOptions().addOption(optionWithID);

		optionWithID = new OptionWithID(40, "output-path",
				"Destination path for the output (if applicable, otherwise ignored). Overrides the profile setting.\n");
				"Destination path for the output (if applicable, otherwise ignored), overrides the profile setting\n");
		optionWithID.setArgs(1);
		optionWithID.setArgName("PATH");
		getOptions().addOption(optionWithID);
@@ -44,6 +44,9 @@ public class OptionsHandler {
		optionWithID = new OptionWithID(100, "help", "Show this usage information screen\n");
		getOptions().addOption(optionWithID);

		optionWithID = new OptionWithID(100, "single-core", "Use single core only (no parallel processing)\n");
		getOptions().addOption(optionWithID);

		optionWithID = new OptionWithID(200, "local-dependencies", "Generate local dependencies\n");
		getOptions().addOption(optionWithID);
	}