public class Main {
    public static void main(String[] args) throws InterruptedException {
        int rows = 1000;
        int cols = 1000;
        double[][] matrix = MatrixGenerator.generateMatrix(rows, cols);

        // Однопоточный вариант
        double[][] singleThreadedMatrix = copyMatrix(matrix);
        long startTime = System.nanoTime();
        SingleThreadedMatrixProcessor.process(singleThreadedMatrix);
        long endTime = System.nanoTime();
        System.out.println("Single-threaded: " + (endTime - startTime) / 1e9 + " сек");

        // Параллельный вариант с ThreadPoolExecutor
        double[][] threadPoolMatrix = copyMatrix(matrix);
        startTime = System.nanoTime();
        ThreadPoolMatrixProcessor.process(threadPoolMatrix, 4); // 4 потока
        endTime = System.nanoTime();
        System.out.println("ThreadPoolExecutor: " + (endTime - startTime) / 1e9 + " сек");

        // Параллельный вариант с ForkJoinPool
        double[][] forkJoinMatrix = copyMatrix(matrix);
        startTime = System.nanoTime();
        ForkJoinMatrixProcessor.process(forkJoinMatrix);
        endTime = System.nanoTime();
        System.out.println("ForkJoinPool: " + (endTime - startTime) / 1e9 + " сек");
    }

    private static double[][] copyMatrix(double[][] matrix) {
        int rows = matrix.length;
        int cols = matrix[0].length;
        double[][] copy = new double[rows][cols];
        for (int i = 0; i < rows; i++) {
            System.arraycopy(matrix[i], 0, copy[i], 0, cols);
        }
        return copy;
    }
}