Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
vertigo - simple java starter Copyright (C) 2013, KleeGroup, ( KleeGroup, Centre d'affaire la Boursidiere - BP 159 - 92357 Le Plessis Robinson Cedex - France Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
Plugin de calcul du temps d'exécution d'une requête.

 public final class PerformanceMetricEngine implements MetricEngine<TaskDefinition> {
 	private final TaskManager taskManager;

Constructeur apr défaut.

taskManager Manager des tasks
 	public PerformanceMetricEngine(final TaskManager taskManager) {
 		this. = taskManager;

 	public Metric execute(final TaskDefinition taskDefinition) {
 		try {
 			return doExecute(taskDefinition);
 		} catch (final Throwable e) {
 			//throw new RiException("Erreur du plugin perfs", e);
 	private static String createValueInformation(final Throwable throwable) {
 		final StringWriter sw = new StringWriter();
 		throwable.printStackTrace(new PrintWriter(sw));
 		return sw.getBuffer().toString();
 	private static Metric buildPerformanceMetric(final Status statusfinal Long executionTimefinal String valueInformation) {
 		return new MetricBuilder()
 				.withTitle("Temps d'exécution")
 	private Metric doExecute(final TaskDefinition taskDefinition) {
 		//System.out.println(">>>>" + currentTask.getEngineClass().getCanonicalName());
 		if (TaskEngineSelect.class.isAssignableFrom(taskDefinition.getTaskEngineClass()) && !hasNotNullOutParams(taskDefinition)) {
 			//	System.out.println(">>>>>>>>>>>>>>>>>>>>>>>>>>>>" + currentTask.getEngineClass().getCanonicalName());
 			final TaskPopulator taskPopulator = new TaskPopulator(taskDefinition);
 			final Task task = taskPopulator.populateTask();
 			final long startTime = System.currentTimeMillis();
 			/*TaskResult result =*/.execute(task);
 			//on n'utilise pas le resultat
 			final long endTime = System.currentTimeMillis();
 			final long executionTime = endTime - startTime;
 			return buildPerformanceMetric(.executionTimenull);
 		//Le test n'a pas de sens.
 		return buildPerformanceMetric(.nullnull);
 	private static boolean hasNotNullOutParams(final TaskDefinition taskDefinition) {
		for (final TaskAttribute attribute : taskDefinition.getAttributes()) {
			if (!attribute.isIn() && attribute.isNotNull()) {
				return true;
		return false;
New to GrepCode? Check out our FAQ X