Commit bb58c495 authored by Noric Couderc's avatar Noric Couderc
Browse files

Fix: Fixed the silent skipping of methods before start()

If you run stuff before calling start(), it's not recorded.
parent d3f04311
......@@ -82,8 +82,8 @@ public class CollectionTimer {
* @param operationType
*/
public void startOperation(OperationType operationType) {
if (!mainStopWatch.isStarted()) { return; }
if (isTopLevel()) {
if (!mainStopWatch.isStarted()) { mainStopWatch.start(); }
StopWatch sw = getStopWatch(operationType);
if (!sw.isStarted()) {
......@@ -102,6 +102,7 @@ public class CollectionTimer {
* @param operationType
*/
public void stopOperation(OperationType operationType) {
if (!mainStopWatch.isStarted()) { return; }
stackLevel++;
if (isTopLevel()) {
suspendStopWatch(operationType);
......
......@@ -3,8 +3,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.infra.Blackhole;
import se.lth.cs.bcgen.BCBenchmarkPackage;
import se.lth.cs.timing.TimedList;
......@@ -74,12 +72,14 @@ public class TimedListsTest {
public void testClear(TimedList<Integer> l) {
l.addAll(List.of(1, 2, 3, 4, 5, 6));
l.start();
l.clear();
l.stop();
Assertions.assertTrue(l.isEmpty());
Assertions.assertTrue(0 < l.getTimeDeletions());
Assertions.assertEquals(0, l.getTimeSearches());
Assertions.assertTrue(0 < l.getTimeInsertions());
Assertions.assertEquals(0, l.getTimeInsertions());
}
@ParameterizedTest()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment