net.digger:utils

A collection of small utility classes.

License

License

Categories

Categories

Net
GroupId

GroupId

net.digger
ArtifactId

ArtifactId

utils
Last Version

Last Version

1.0.0
Release Date

Release Date

Type

Type

jar
Description

Description

net.digger:utils
A collection of small utility classes.
Project URL

Project URL

https://github.com/diggernet/JavaUtils
Source Code Management

Source Code Management

https://github.com/diggernet/JavaUtils/tree/develop

Download utils

How to add to project

<!-- https://jarcasting.com/artifacts/net.digger/utils/ -->
<dependency>
    <groupId>net.digger</groupId>
    <artifactId>utils</artifactId>
    <version>1.0.0</version>
</dependency>
// https://jarcasting.com/artifacts/net.digger/utils/
implementation 'net.digger:utils:1.0.0'
// https://jarcasting.com/artifacts/net.digger/utils/
implementation ("net.digger:utils:1.0.0")
'net.digger:utils:jar:1.0.0'
<dependency org="net.digger" name="utils" rev="1.0.0">
  <artifact name="utils" type="jar" />
</dependency>
@Grapes(
@Grab(group='net.digger', module='utils', version='1.0.0')
)
libraryDependencies += "net.digger" % "utils" % "1.0.0"
[net.digger/utils "1.0.0"]

Dependencies

test (2)

Group / Artifact Type Version
junit : junit jar 4.12
org.hamcrest : hamcrest-library jar 1.3

Project Modules

There are no modules declared in this project.

JavaUtils

JavaUtils is a collection of small utility classes. It includes tools to pause a thread with finer control than the standard tools, and to measure elapsed time.

Maven configuration

	<dependency>
		<groupId>net.digger</groupId>
		<artifactId>utils</artifactId>
		<version>1.0.0</version>
	</dependency>

Pause

Pause is a tool to pause a thread for a period of time, with finer control than the standard tools. For example, you could call

	TimeUnit.MICROSECONDS.sleep(micros);

or

	TimeUnit.NANOSECONDS.sleep(nanos);

but currently both of those internally just call

	Thread.sleep(millis);

so you don't have any control below 1 millisecond.

Pause gives you control well below that threshold, down to microseconds and makes a good effort at nanoseconds. Precision at that level depends on your machine and your JVM. I get good results down to around a few tens of microseconds. Your results may vary.

Usage

	Pause.second(seconds);

	Pause.milli(milliseconds);

	Pause.micro(microseconds);

	Pause.nano(nanoseconds);

Timer

A simple little tool to quickly check the elapsed time for a block of code.

Usage

	long elapsed = Timer.time(() -> {
		// your code here
	});

License

These utilities are provided under the terms of the GNU LGPLv3.

Versions

Version
1.0.0