Repository navigation
Expand file tree
/
Copy pathtime_test_fibo.c
More file actions
130 lines (95 loc) · 2.88 KB
/
Copy pathtime_test_fibo.c
File metadata and controls
130 lines (95 loc) · 2.88 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<<<<<<< HEAD
//
// time_test_fibo.c
//
//
// Created by Cesar Angeles on 07/09/2020.
//
#include <stdio.h>
#include <time.h>
#include "Sequences.h"
#include "files.h"
#include "time_test_fibo.h"
int main(void){
long long int value = 0;
int index = 0;
clock_t start, stop;
double cpu_time = 0;
double mean = 0;
FILE * record = NULL;
long double buffer[OBSERVATIONS][VALUES] = {0};
size_t obs = 0;
record = file_new("FIBO_TIME.dat","w");
//puts("Enter n fibo value:");
//scanf("%lld", &value);
printf("%lld\t", value);
for (obs = 0; obs < OBSERVATIONS; obs ++){
printf("%zu\n",obs);
start = clock();
for (index = 0; index <= STATISTIC; index ++){
Sequences_rfibo(obs);
}
stop = clock();
cpu_time = ((double)(stop-start)) /CLOCKS_PER_SEC / STATISTIC;
buffer[obs][INDEX] = obs;
buffer[obs][RECURSIVE] = cpu_time;
printf("Recursive Fibo time %f s\t", cpu_time);
start = clock();
for (index = 0; index <= STATISTIC; index ++){
Sequences_sfibo(obs);
}
stop = clock();
cpu_time = ((double)(stop-start)) /CLOCKS_PER_SEC / STATISTIC;
buffer[obs][ITERATIVE] = cpu_time*1e3;
printf("Sequential Fibo time %f ms\n", cpu_time*1e3);
}
file_num_write(record, VALUES, buffer, OBSERVATIONS);
fclose(record);
}
||||||| f46ea0f
=======
//
// time_test_fibo.c
//
//
// Created by Cesar Angeles on 07/09/2020.
//
#include <stdio.h>
#include <time.h>
#include "Sequences.h"
#include "files.h"
#include "time_test_fibo.h"
int main(void){
long long int value = 0;
int index = 0;
clock_t start, stop;
double cpu_time = 0;
double mean = 0;
FILE * record = NULL;
long double buffer[OBSERVATIONS][VALUES] = {0};
size_t obs = 0;
record = file_new("FIBO_TIME.dat","w");
for(obs = 0; obs < OBSERVATIONS; obs ++) {
printf("%zu\n", obs);
start = clock();
for (index = 0; index <= STATISTIC; index ++){
Sequences_rfibo(obs);
}
stop = clock();
cpu_time = ((double)(stop-start)) /CLOCKS_PER_SEC / STATISTIC;
buffer[obs][INDEX] = obs;
buffer[obs][RECURSIVE] = cpu_time;
printf("Recursive Fibo time %f s\t", cpu_time);
start = clock();
for (index = 0; index <= STATISTIC; index ++){
Sequences_sfibo(obs);
}
stop = clock();
cpu_time = ((double)(stop-start)) /CLOCKS_PER_SEC / STATISTIC;
buffer[obs][ITERATIVE] = cpu_time*1e3;
printf("Sequential Fibo time %f ms\n", cpu_time*1e3);
}
file_num_write(record, VALUES, buffer, OBSERVATIONS);
fclose(record);
}
>>>>>>> e94102e9b652f269c770d77c8267559b161b52fd