added some JavaDoc

This commit is contained in:
2020-05-05 13:32:26 +02:00
parent a1d4cbc462
commit 0839b32c14
28 changed files with 102 additions and 14 deletions
@@ -30,8 +30,11 @@ import de.unidue.nes.gpu.testframework.tasks.GpuTask;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* The "main" interface to the testing framework
*
* @author Roch P., Shahbaz Nejad B.
*
* @param <T> Type of input
*/
public class TestUtils<T> {
@@ -51,19 +54,25 @@ public class TestUtils<T> {
}
/**
* @param commands
* @param commands the command pipeline
*/
public void setCommandPipeline(Consumer<Input<T>> commands) {
checkNotInitialized();
this.commands = commands;
}
/**
* used to specify the input to the command pipeline
*/
public void setInput(Input<T> input) {
checkNotInitialized();
this.originalInput = input;
this.input = input.createCopy();
}
/**
* use this to initialize the commands
*/
public void initializeCommands() {
checkNotInitialized();
checkFieldsAreSet();
@@ -77,16 +86,31 @@ public class TestUtils<T> {
Objects.requireNonNull(this.input);
}
/**
* warmup method
*
* @param iterations the number of warmup iterations
*/
public void warmup(int iterations) {
warmupCPUTests(iterations);
warmupGPUTests(iterations);
}
/**
* run the tests
*
* @param iterations the number of iterations to test
*/
public void runTests(int iterations) {
runCPUTests(iterations);
runGPUTests(iterations);
}
/**
* only warmup cpu tests
*
* @param iterations the number of warmup iterations
*/
public void warmupCPUTests(int iterations) {
checkInitialized();
for (int i = 0; i < iterations; i++) {
@@ -99,6 +123,11 @@ public class TestUtils<T> {
resetTasks();
}
/**
* only warmup gpu tests
*
* @param iterations the number of warmup iterations
*/
public void warmupGPUTests(int iterations) {
checkInitialized();
for (int i = 0; i < iterations; i++) {
@@ -166,6 +195,11 @@ public class TestUtils<T> {
}
}
/**
* only run cpu tests
*
* @param iterations the number of iterations
*/
public void runCPUTests(int iterations) {
checkInitialized();
List<Task> tasks = TestPipeline.INSTANCE.getPipeline();
@@ -196,6 +230,11 @@ public class TestUtils<T> {
ResultHandler.newResult(new Result(tasks.get(index), TestExecution.CPU, time));
}
/**
* only run gpu tests
*
* @param iterations the number of iterations
*/
public void runGPUTests(int iterations) {
testUploadAndDownload(iterations);
List<Task> tasks = TestPipeline.INSTANCE.getPipeline();
@@ -285,6 +324,9 @@ public class TestUtils<T> {
}
}
/**
* used to start the evaluation
*/
public void evaluate() {
ResultHandler.evaluate();
}
@@ -1,8 +1,9 @@
package de.unidue.nes.gpu.testframework.exception;
/**
* This exception is thrown when the initialization is triggered twice
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public class AlreadyInitializedException extends RuntimeException {
@@ -1,8 +1,10 @@
package de.unidue.nes.gpu.testframework.exception;
/**
* This exception is thrown when the testing framework was not initialized
* properly.
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public class NotInitializedException extends RuntimeException {
@@ -1,6 +1,8 @@
package de.unidue.nes.gpu.testframework.input;
/**
* A generic interface for all kinds of input
*
* @author Roch P., Shahbaz Nejad B.
*/
public interface Input<T> {
@@ -3,6 +3,8 @@ package de.unidue.nes.gpu.testframework.input;
import org.opencv.core.Mat;
/**
* An implementation for the input interface wrapping a Mat as input
*
* @author Roch P., Shahbaz Nejad B.
*/
public class MatInput implements Input<Mat> {
@@ -1,6 +1,8 @@
package de.unidue.nes.gpu.testframework.internal.mathandling;
/**
* A converter to convert between JavaCV and OpenCV Mats
*
* @author Roch P., Shahbaz Nejad B.
*/
public class MatConverter {
@@ -9,6 +9,8 @@ import org.bytedeco.opencv.opencv_core.Mat;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* A pool of Mats and GpuMats
*
* @author Roch P., Shahbaz Nejad B.
*/
public class MatPool {
@@ -6,6 +6,11 @@ import org.opencv.core.Mat;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* A combination of a Mat and a Task
*
* @author Roch P., Shahbaz Nejad B.
*/
public final class MatTaskTuple {
private final Mat mat;
@@ -8,6 +8,8 @@ import org.opencv.core.Mat;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* This class is used to capture uploads and downloads
*
* @author Roch P., Shahbaz Nejad B.
*/
public class UploadDownloadCaptor {
@@ -6,6 +6,8 @@ import java.util.List;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* The pipeline of tasks
*
* @author Roch P., Shahbaz Nejad B.
*/
public class TestPipeline {
@@ -4,6 +4,8 @@ import de.unidue.nes.gpu.testframework.internal.timing.TimeDto;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* a testing result
*
* @author Roch P., Shahbaz Nejad B.
*/
public class Result {
@@ -20,6 +20,8 @@ import de.unidue.nes.gpu.testframework.tasks.GpuTask;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* a class collecting all results and computing the final result
*
* @author Roch P., Shahbaz Nejad B.
*/
public class ResultHandler {
@@ -1,8 +1,9 @@
package de.unidue.nes.gpu.testframework.internal.resulthandling;
/**
* An enum to differentiate between CPU and GPU test execution
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public enum TestExecution {
CPU, GPU
@@ -9,8 +9,9 @@ import de.unidue.nes.gpu.testframework.tasks.GpuTask;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* The task to download Mats
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public class DownloadTask implements Task {
@@ -9,6 +9,9 @@ import de.unidue.nes.gpu.testframework.tasks.GpuTask;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* Some generic GPU task to delegate to the cpu implementation if no gpu
* implementation is present
*
* @author Roch P., Shahbaz Nejad B.
*/
public class GenericGpuTask implements GpuTask {
@@ -10,8 +10,9 @@ import de.unidue.nes.gpu.testframework.tasks.GpuTask;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* a task testing the time of page-locked uploading
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public class PagelockedUploadTask implements Task {
@@ -5,8 +5,9 @@ import de.unidue.nes.gpu.testframework.tasks.GpuTask;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* a task testing the pipeline of opencv functions
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public class PipelineTask implements Task {
@@ -9,8 +9,9 @@ import de.unidue.nes.gpu.testframework.tasks.GpuTask;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* a task testing uploading of Mats
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public class UploadTask implements Task {
@@ -14,8 +14,9 @@ import de.unidue.nes.gpu.testframework.tasks.GpuTask;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* the Imgproc.Canny function
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public class Canny implements Task {
@@ -13,8 +13,9 @@ import de.unidue.nes.gpu.testframework.tasks.GpuTask;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* the Imgproc.cvtColor function
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public class CvtColor implements Task {
@@ -14,6 +14,8 @@ import de.unidue.nes.gpu.testframework.tasks.GpuTask;
import de.unidue.nes.gpu.testframework.tasks.Task;
/**
* the Imgproc.medianBlur function
*
* @author Roch P., Shahbaz Nejad B.
*/
public class MedianBlur implements Task {
@@ -3,6 +3,8 @@ package de.unidue.nes.gpu.testframework.internal.timing;
import java.util.concurrent.TimeUnit;
/**
* timing information
*
* @author Roch P., Shahbaz Nejad B.
*/
public class TimeDto {
@@ -3,8 +3,9 @@ package de.unidue.nes.gpu.testframework.internal.timing;
import java.util.concurrent.TimeUnit;
/**
* This class is used to time certain method calls
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public class TimingUtil {
@@ -8,8 +8,9 @@ import de.unidue.nes.gpu.testframework.internal.tasks.imgproc.CvtColor;
import de.unidue.nes.gpu.testframework.internal.tasks.imgproc.MedianBlur;
/**
* A replacement for the real Imgproc
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public class Imgproc {
@@ -1,8 +1,9 @@
package de.unidue.nes.gpu.testframework.tasks;
/**
* the interface of a task run on the cpu
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public interface CpuTask extends Runnable {
@@ -3,6 +3,8 @@ package de.unidue.nes.gpu.testframework.tasks;
import de.unidue.nes.gpu.testframework.internal.pipeline.TestPipeline;
/**
* use this to add custom tasks to the pipeline
*
* @author Roch P., Shahbaz Nejad B.
*/
public class CustomTask {
@@ -1,8 +1,9 @@
package de.unidue.nes.gpu.testframework.tasks;
/**
* a task run on the gpu
*
* @author Roch P., Shahbaz Nejad B.
*
*/
public interface GpuTask extends Runnable {
@@ -1,6 +1,8 @@
package de.unidue.nes.gpu.testframework.tasks;
/**
* a high-level interface for a any task
*
* @author Roch P., Shahbaz Nejad B.
*/
public interface Task {