C-Programming/Sorting/src/main.c

47 lines
1.3 KiB
C
Raw Normal View History

2023-04-21 10:39:00 +00:00
/**
* Generic test class for implementing
* functions for benchmarking sorting functions
* _ _ _ _
* __ ___ __(_) |_| |_ ___ _ __ | |__ _ _
* \ \ /\ / / '__| | __| __/ _ \ '_ \ | '_ \| | | |
* \ V V /| | | | |_| || __/ | | | | |_) | |_| |
* \_/\_/ |_| |_|\__|\__\___|_| |_| |_.__/ \__, |
* |___/
* ____ __ __ _
* / ___|_ _____ _ __ \ \ / /__ __ _ ___| |
* \___ \ \ / / _ \ '_ \ \ \ / / _ \ / _` |/ _ \ |
* ___) \ V / __/ | | | \ V / (_) | (_| | __/ |
* |____/ \_/ \___|_| |_| \_/ \___/ \__, |\___|_|
* |___/
* Licensed under the GPLv2 License, Version 2.0 (the "License");
* Copyright (c) Sven Vogel
*/
2023-04-19 10:53:07 +00:00
#include "arrays.h"
#include "bench.h"
#include "sort.h"
#include <stdlib.h>
#include <time.h>
const int LEN = 10000;
const Sort TESTS[] = {
{"bubble", bubble}, {"gnome", gnome}, {"selection", selection},
{"quick", quick}, {"merge", merge}, {"shell", shell},
{"insertion", insertion}, {"radix", radix},
};
int main() {
int *arr = (int *)malloc(sizeof(int) * LEN);
populate(arr, LEN);
srand(time(NULL));
benchmark(TESTS, sizeof(TESTS) / sizeof(Sort), arr, LEN);
free(arr);
return 0;
}