All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.continuity.commons.utils.JMeterUtils Maven / Gradle / Ivy

package org.continuity.commons.utils;

import org.apache.jmeter.threads.ThreadGroup;
import org.apache.jorphan.collections.ListedHashTree;
import org.apache.jorphan.collections.SearchByClass;

/**
 * Provides utility functionality for JMeter test plans.
 *
 * @author Henning Schulz
 *
 */
public class JMeterUtils {

	private JMeterUtils() {
	}

	/**
	 * Extracts the configured duration of the test plan.
	 *
	 * @param testPlan
	 *            The test plan.
	 * @return The duration.
	 */
	public static long getDuration(ListedHashTree testPlan) {
		SearchByClass search = new SearchByClass<>(ThreadGroup.class);
		testPlan.traverse(search);

		for (ThreadGroup group : search.getSearchResults()) {
			return group.getDuration();
		}

		return -1;
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy