private void benchmark() {
        stage.hide();
        secondaryStage = new Stage(StageStyle.UTILITY);
        secondaryStage.setTitle("Benchmarking...");
        StackPane sp = new StackPane();
        benchmarkBar = new ProgressBar();
        benchmarkBar.setPrefWidth(400);
        benchmarkBar.setPrefHeight(30);
        benchmarkBar.setProgress(-1);
        sp.getChildren().add(benchmarkBar);
        secondaryStage.setScene(new Scene(sp, 400, 30));
        secondaryStage.show();
        benchSide = mazeGrid.getSideCount();
        benchWalls = mazeGrid.getWalls();
        benchDiag = noDiagonal.isSelected();

        benchmarkData = new long[BENCHMARK_ITERATIONS];
        if (mazeGrid.hasStartAndEnd()) {
            perfectRoute = Math.sqrt(Math.pow(mazeGrid.getGoal().x - mazeGrid.getStart().x, 2)
                    + Math.pow(mazeGrid.getGoal().y - mazeGrid.getStart().y, 2));
            final Task<List<Point>> tsk = new Task<List<Point>>() {
                @Override
                protected List<Point> call() {
                    long timeStamp;
                    for(int i=0; i<MazeFramework.BENCHMARK_ITERATIONS-1; i++) {
                        if(!isCancelled()) {
                            timeStamp = System.nanoTime();
                            MazeFramework.algorithm.initPathfinder(mazeGrid.getConvertedGrid(), mazeGrid.getStart(), mazeGrid.getGoal());
                            MazeFramework.algorithm.startPathfinder(noDiagonal.isSelected());
                            benchmarkData[i] = (System.nanoTime() - timeStamp);
                            updateProgress(i, MazeFramework.BENCHMARK_ITERATIONS);
                        }
                    }
                    timeStamp = System.nanoTime();
                    List<Point> res = MazeFramework.algorithm.startPathfinder(noDiagonal.isSelected());
                    benchmarkData[MazeFramework.BENCHMARK_ITERATIONS-1] = (System.nanoTime()-timeStamp);
                    if(res!=null) { 
                        steps = res.size();
                    }
                    return res;
                }
            };

            tsk.setOnSucceeded(new EventHandler<WorkerStateEvent>() {
                @Override
                public void handle(WorkerStateEvent t) {
                    secondaryStage.hide();
                    showBenchmarkResults();
                    mazeGrid.overlaySolution((List<Point>) t.getSource().getValue());
                    
                }
            });

            tsk.setOnFailed(new EventHandler<WorkerStateEvent>() {
                @Override
                public void handle(WorkerStateEvent t) {
                    secondaryStage.hide();
                    stage.show();
                    try {
                        throw t.getSource().getException();
                    } catch (Throwable ex) {
                        Logger.getLogger(MazeFramework.class.getName()).log(Level.SEVERE, null, ex);
                    }
                }
            });

            secondaryStage.setOnHidden(new EventHandler<WindowEvent>() {
                @Override
                public void handle(WindowEvent t) {
                    tsk.cancel();
                    stage.show();
                }
            });
            
            benchmarkBar.progressProperty().bind(tsk.progressProperty());
            Thread thrd = new Thread(tsk);
            thrd.start();

        } else {
            JOptionPane.showMessageDialog(null, "Goal and Start positions are not set!", "Can't run!", JOptionPane.WARNING_MESSAGE);
            stage.show();
        } 
    }