-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
53 lines (42 loc) · 1.33 KB
/
main.cpp
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
// Radix Pointer Sort.cpp : Defines the entry point for the console application.
//
#include "ptrRadix.h"
#include <stdio.h>
#include <sys/time.h>
#include <fstream>
int main()
{
struct timeval t1, t2;
double elapsedTime;
int size, dim;
size = 1000;
dim = 9;
//int arr [] = { 314, 563, 789, 543, 123, 124, 878, 877 };
int arr[size];
ifstream myReadFile;
myReadFile.open("./data2/9");
if (myReadFile.fail())
cout << "Could Not Open File\n";
else
cout << "File opened succesfully\n";
char output[100];
int i = 0;
if (myReadFile.is_open()) {
while (!myReadFile.eof()) {
myReadFile >> output;
arr[i] = atoi(output);
i++;
}
}
gettimeofday(&t1, NULL);
ptrSort(arr, size, dim);
gettimeofday(&t2, NULL);
/*for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)
{
cout << arr[i] << "\n";
}*/
elapsedTime = (t2.tv_sec - t1.tv_sec) * 1000.0; // sec to ms
elapsedTime += (t2.tv_usec - t1.tv_usec) / 1000.0; // us to ms
cout <<"Time: " << elapsedTime << " ms.\n";
return 0;
}