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

org.javasimon.testapp.UniformRandomTimer Maven / Gradle / Ivy

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

import org.javasimon.testapp.test.Timer;

import java.util.Random;

/**
 * Class UniformRandomTimer.
 *
 * @author Radovan Sninsky
 * @since 2.0
 */
public class UniformRandomTimer implements Timer {

	private final Random random = new Random();

	private long range;
	private long delay;

	public UniformRandomTimer(long range, long delay) {
		this.range = range;
		this.delay = delay;
	}

	public long getRange() {
		return range;
	}

	public long getDelay() {
		return delay;
	}

	public long delay() {
		return (long) Math.abs((this.random.nextDouble() * getRange()) + getDelay());
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy