source/benchmark.c
void saveResults(double cpu_time_used, double memory_used, int algorithm, int vector_size, int generation_type)
{
    FILE *BenchmarkResults;
    BenchmarkResults = fopen("Benchmark\\BenchmarkResults.dat", "a");

    if(BenchmarkResults == NULL)
    {
        printf("Error!\n");
        exit(2); //Means that the program has failed to create/open a .dat file to write results.
    }
    else
    {
        fprintf(BenchmarkResults, "Algorithm: ");

        switch(algorithm)
        {
            case 1:
                fprintf(BenchmarkResults, "Bubble Sort.\n");
                break;

            case 2:
                fprintf(BenchmarkResults, "Selection Sort.\n");
                break;

            case 3:
                fprintf(BenchmarkResults, "Insertion Sort.\n");
                break;

            case 4:
                fprintf(BenchmarkResults, "Shell Sort.\n");
                break;

            case 5:
                fprintf(BenchmarkResults, "Heap Sort.\n");
                break;

            case 6:
                fprintf(BenchmarkResults, "Merge Sort.\n");
                break;

            case 7:
                fprintf(BenchmarkResults, "Quick Sort.\n");
                break;

            case 8:
                fprintf(BenchmarkResults, "Counting Sort.\n");
                break;

            default:
                printf("Error!\n");
                exit(3); //Means that the algorithm value is invalid.
        }

        fprintf(BenchmarkResults, "Vector Size: %d.\n", vector_size);
        fprintf(BenchmarkResults, "Vector Generation Type: ");

        switch(generation_type)
        {
            case 1:
                fprintf(BenchmarkResults, "Ascending.\n");
                break;

            case 2:
                fprintf(BenchmarkResults, "Descending.\n");
                break;

            case 3:
                fprintf(BenchmarkResults, "Random.\n");
                break;

            default:
                printf("Error!\n");
                exit(4); //Means that the vector generation type is invalid.
        }

        fprintf(BenchmarkResults, "Runtime: %f Seconds.\n", cpu_time_used);
        fprintf(BenchmarkResults, "Memory Usage: %f MB.\n\n\n\n", memory_used);
    }

    printf("Results saved.\n");
    printf("------------------------------\n\n\n\n");

    fclose(BenchmarkResults);
}
//Receives data from "benchmark" function and converts into a .dat file (BenchmarkResults.dat).

Receives data from "benchmark" function and converts into a .dat file (BenchmarkResults.dat).
Receives data from " benchmark " function and converts into a . dat file ( BenchmarkResults . dat ) .
void saveResults(double cpu_time_used, double memory_used, int algorithm, int vector_size, int generation_type)
{
    FILE *BenchmarkResults;
    BenchmarkResults = fopen("Benchmark\\BenchmarkResults.dat", "a");
    if(BenchmarkResults == NULL)
    {
        printf("Error!\n");
        exit(2); 
    }
    else
    {
        fprintf(BenchmarkResults, "Algorithm: ");
        switch(algorithm)
        {
            case 1:
                fprintf(BenchmarkResults, "Bubble Sort.\n");
                break;
            case 2:
                fprintf(BenchmarkResults, "Selection Sort.\n");
                break;
            case 3:
                fprintf(BenchmarkResults, "Insertion Sort.\n");
                break;
            case 4:
                fprintf(BenchmarkResults, "Shell Sort.\n");
                break;
            case 5:
                fprintf(BenchmarkResults, "Heap Sort.\n");
                break;
            case 6:
                fprintf(BenchmarkResults, "Merge Sort.\n");
                break;
            case 7:
                fprintf(BenchmarkResults, "Quick Sort.\n");
                break;
            case 8:
                fprintf(BenchmarkResults, "Counting Sort.\n");
                break;
            default:
                printf("Error!\n");
                exit(3); 
        }
        fprintf(BenchmarkResults, "Vector Size: %d.\n", vector_size);
        fprintf(BenchmarkResults, "Vector Generation Type: ");
        switch(generation_type)
        {
            case 1:
                fprintf(BenchmarkResults, "Ascending.\n");
                break;
            case 2:
                fprintf(BenchmarkResults, "Descending.\n");
                break;
            case 3:
                fprintf(BenchmarkResults, "Random.\n");
                break;
            default:
                printf("Error!\n");
                exit(4); 
        }
        fprintf(BenchmarkResults, "Runtime: %f Seconds.\n", cpu_time_used);
        fprintf(BenchmarkResults, "Memory Usage: %f MB.\n\n\n\n", memory_used);
    }
    printf("Results saved.\n");
    printf("------------------------------\n\n\n\n");
    fclose(BenchmarkResults);
}
void saveResults ( double cpu_time_used , double memory_used , int algorithm , int vector_size , int generation_type ) { FILE * BenchmarkResults ; BenchmarkResults = fopen ( " \\ " , " " ) ; if ( BenchmarkResults == NULL ) { printf ( " \n " ) ; exit ( 2 ) ; } else { fprintf ( BenchmarkResults , " " ) ; switch ( algorithm ) { case 1 : fprintf ( BenchmarkResults , " \n " ) ; break ; case 2 : fprintf ( BenchmarkResults , " \n " ) ; break ; case 3 : fprintf ( BenchmarkResults , " \n " ) ; break ; case 4 : fprintf ( BenchmarkResults , " \n " ) ; break ; case 5 : fprintf ( BenchmarkResults , " \n " ) ; break ; case 6 : fprintf ( BenchmarkResults , " \n " ) ; break ; case 7 : fprintf ( BenchmarkResults , " \n " ) ; break ; case 8 : fprintf ( BenchmarkResults , " \n " ) ; break ; default : printf ( " \n " ) ; exit ( 3 ) ; } fprintf ( BenchmarkResults , " \n " , vector_size ) ; fprintf ( BenchmarkResults , " " ) ; switch ( generation_type ) { case 1 : fprintf ( BenchmarkResults , " \n " ) ; break ; case 2 : fprintf ( BenchmarkResults , " \n " ) ; break ; case 3 : fprintf ( BenchmarkResults , " \n " ) ; break ; default : printf ( " \n " ) ; exit ( 4 ) ; } fprintf ( BenchmarkResults , " \n " , cpu_time_used ) ; fprintf ( BenchmarkResults , " \n \n \n \n " , memory_used ) ; } printf ( " \n " ) ; printf ( " \n \n \n \n " ) ; fclose ( BenchmarkResults ) ; }
Receives data from "benchmark" function and converts into a .dat file (BenchmarkResults.dat).
Receives data from " benchmark " function and converts into a . dat file ( BenchmarkResults . dat ) .
//Means that the program has failed to create/open a .dat file to write results.
 //Means that the algorithm value is invalid.
 //Means that the vector generation type is invalid.
