-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
53 lines (45 loc) · 1.31 KB
/
main.c
File metadata and controls
53 lines (45 loc) · 1.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "Merge_Sort_Bottom_up.h"
int main()
{
unsigned long long int start_ns; // Nanoseconds
time_t start_s; // Seconds
unsigned long long int stop_ns; // Nanoseconds
time_t stop_s; // Seconds
struct timespec spec;
clock_gettime(CLOCK_MONOTONIC, &spec);
start_s = spec.tv_sec;
start_ns = (unsigned long long int)spec.tv_nsec;
//start_ns %= (unsigned long long int)1e9;
long nb_line = 0;
char *line = NULL;
long **tabs = NULL;
tabs = store_numbers(NULL, NULL, line, &nb_line);
long *C = BottomUpMergeSort(tabs[0], tabs[1], nb_line - 1);
long i = -1;
while (++i < nb_line - 1)
// printf("%li\n", C[i]);
if(C)
continue;
if (tabs[0] != NULL)
{
free(tabs[0]);
tabs[0] = NULL;
}
if (tabs[1] != NULL)
{
free(tabs[1]);
tabs[1] = NULL;
}
if (tabs != NULL)
{
free(tabs);
tabs = NULL;
}
clock_gettime(CLOCK_MONOTONIC, &spec);
stop_s = spec.tv_sec;
stop_ns = (unsigned long long int)spec.tv_nsec;
//stop_ns %= (unsigned long long int)1e9;
printf("Elapsed time: %"PRIdMAX" seconds or %llu nanoseconds\n", \
(intmax_t)stop_s - (intmax_t)start_s, stop_ns - start_ns);
return 0;
}