/*
 * Java Genetic Algorithm Library (@__identifier__@).
 * Copyright (c) @__year__@ Franz Wilhelmstötter
 *
 * 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
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 *
 * Author:
 *    Franz Wilhelmstötter (franz.wilhelmstoetter@gmx.at)
 */
package org.jenetics.internal.util;

import static java.util.Objects.requireNonNull;

import java.time.Clock;
import java.time.Duration;
import java.time.Instant;

/**
 * @author <a href="mailto:franz.wilhelmstoetter@gmx.at">Franz Wilhelmstötter</a>
 * @since 3.0
 * @version 3.0 &mdash; <em>$Date: 2014-08-07 $</em>
 */
public final class Timer {

	private final Clock _clock;

    private Instant _start;
    private Instant _stop;

	private Timer(final Clock clock) {
		_clock = requireNonNull(clock);
	}

	public Timer start() {
        _start = _clock.instant();
		return this;
	}

	public Timer stop() {
		_stop = _clock.instant();
		return this;
	}

    public Duration getTime() {
        return minus(_stop, _start);
    }

	private static Duration minus(final Instant a, final Instant b)  {
		final long seconds = a.getEpochSecond() - b.getEpochSecond();
		final long nanos = a.getNano() - b.getNano();

		return Duration.ofNanos(seconds*NanoClock.NANOS_PER_SECOND + nanos);
	}

    public static Timer of(final Clock clock) {
        return new Timer(clock);
    }

    public static Timer of() {
        return of(NanoClock.INSTANCE);
    }

}

@@ -902,16 +902,78 @@
 t;%0A%0A/**%0A
+ * Timer implementation for measuring execution durations.%0A *%0A
  * @auth
@@ -1301,24 +1301,111 @@
 clock);%0A%09%7D%0A%0A
+%09/**%0A%09 * Start the timer.%0A%09 *%0A%09 * @return %7B@code this%7D timer, for method chaining%0A%09 */%0A
 %09public Time
@@ -1416,24 +1416,18 @@
 art() %7B%0A
-        
+%09%09
 _start =
@@ -1469,496 +1469,1073 @@
 %7D%0A%0A%09
-public Timer stop() %7B%0A%09%09_stop = _clock.instant();%0A%09%09return this;%0A%09%7D%0A%0A    public Duration getTime() %7B%0A        return minus(_stop, _start);%0A    %7D%0A%0A%09private static Duration minus(final Instant a, final Instant b)  %7B%0A%09%09final long seconds = a.getEpochSecond() - b.getEpochSecond();%0A%09%09final long nanos = a.getNano() - b.getNano();%0A%0A%09%09return Duration.ofNanos(seconds*NanoClock.NANOS_PER_SECOND + nanos);%0A%09%7D%0A%0A    public static Timer of(final Clock clock) %7B%0A        return new Timer(clock);%0A    %7D%0A
+/**%0A%09 * Stop the timer.%0A%09 *%0A%09 * @return %7B@code this%7D timer, for method chaining%0A%09 */%0A%09public Timer stop() %7B%0A%09%09_stop = _clock.instant();%0A%09%09return this;%0A%09%7D%0A%0A%09/**%0A%09 * Return the duration between two consecutive %7B@link #start()%7D and%0A%09 * %7B@link #stop()%7D calls.%0A%09 *%0A%09 * @return the duration between two %7B@code start%7D and %7B@code stop%7D calls%0A%09 */%0A    public Duration getTime() %7B%0A        return minus(_stop, _start);%0A    %7D%0A%0A%09private static Duration minus(final Instant a, final Instant b)  %7B%0A%09%09final long seconds = a.getEpochSecond() - b.getEpochSecond();%0A%09%09final long nanos = a.getNano() - b.getNano();%0A%0A%09%09return Duration.ofNanos(seconds*NanoClock.NANOS_PER_SECOND + nanos);%0A%09%7D%0A%0A%09/**%0A%09 * Return an new timer object which uses the given clock for measuring the%0A%09 * execution time.%0A%09 *%0A%09 * @param clock the clock used for measuring the execution time%0A%09 * @return a new timer%0A%09 */%0A    public static Timer of(final Clock clock) %7B%0A        return new Timer(clock);%0A    %7D%0A%0A%09/**%0A%09 * Return an new timer object with the default clock implementation.%0A%09 *%0A%09 * @return a new timer%0A%09 */
 %0A   

Add javadoc.