| 1 | package com.renomad.minum.testing; | |
| 2 | ||
| 3 | /** | |
| 4 | * This class provides some tools for running a virtual stopwatch | |
| 5 | * while code is running, to examine code speed. | |
| 6 | * <h3> | |
| 7 | * example: | |
| 8 | * </h3> | |
| 9 | * | |
| 10 | * <pre> | |
| 11 | {@code | |
| 12 | final var timer = new StopWatch().startTimer(); | |
| 13 | for (var i = 1; i < 5; i++) { | |
| 14 | doStuff(); | |
| 15 | } | |
| 16 | final var time = timer.stopTimer(); | |
| 17 | printf("time taken was " + time " + milliseconds"); | |
| 18 | } | |
| 19 | * </pre> | |
| 20 | */ | |
| 21 | public final class StopwatchUtils { | |
| 22 | ||
| 23 | private long startTime; | |
| 24 | ||
| 25 | public StopwatchUtils startTimer() { | |
| 26 | this.startTime = System.currentTimeMillis(); | |
| 27 |
1
1. startTimer : replaced return value with null for com/renomad/minum/testing/StopwatchUtils::startTimer → KILLED |
return this; |
| 28 | } | |
| 29 | ||
| 30 | public StopwatchUtils() { | |
| 31 | startTime = 0; | |
| 32 | } | |
| 33 | ||
| 34 | ||
| 35 | public long stopTimer() { | |
| 36 | final var endTime = System.currentTimeMillis(); | |
| 37 |
2
1. stopTimer : Replaced long subtraction with addition → KILLED 2. stopTimer : replaced long return with 0 for com/renomad/minum/testing/StopwatchUtils::stopTimer → KILLED |
return endTime - startTime; |
| 38 | } | |
| 39 | } | |
Mutations | ||
| 27 |
1.1 |
|
| 37 |
1.1 2.2 |