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

org.javasimon.examples.LoopingRandomMethod Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
package org.javasimon.examples;

import org.javasimon.SimonManager;
import org.javasimon.Stopwatch;
import org.javasimon.Split;

/**
 * Simple example of the measuring a method in a loop. Method takes random time to finish.
 */
public final class LoopingRandomMethod {
	/**
	 * Entry point to the Example.
	 *
	 * @param args unused
	 */
	public static void main(String[] args) {
		Stopwatch stopwatch = SimonManager.getStopwatch("stopwatch");
		for (int i = 1; i <= 10; i++) {
			Split split = SimonManager.getStopwatch("stopwatch").start();
			ExampleUtils.waitRandomlySquared(50);
			split.stop();
			System.out.println("Stopwatch after round " + i + ": " + stopwatch);
		}
		System.out.println("stopwatch.sample() = " + stopwatch.sample());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy