-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexperiment.cc
61 lines (47 loc) · 1.52 KB
/
experiment.cc
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
///////////////////////////////////////////////////////////////////////////
experiment.cc
// Example code showing how to run an algorithm once and measure its elapsed
time precisely. You should modify this program to gather all of your
experimental data.
///////////////////////////////////////////////////////////////////////////
#include <iostream>
#include "project1.hh"
#include "timer.hh"
using namespace std;
int main() {
string_vector all_words;
if ( ! load_words(all_words, "words.txt") ) {
cerr << "error: cannot open \"words.txt\"" << endl;
return 1;
}
int n = 100;
string_vector n_words(all_words.begin(), all_words.begin() + n);
Timer timer;
auto output = longest_mirrored_string(n_words);
double elapsed = timer.elapsed();
cout << "longest_mirrored_string, "
<< "n=" << n << ", "
<< "output=\"" << output << "\", "
<< "elapsed time=" << elapsed << " seconds" << endl;
timer.reset();
output = character_mode(n_words);
elapsed = timer.elapsed();
cout << "character_mode, "
<< "n=" << n << ", "
<< "output=\"" << output << "\", "
<< "elapsed time=" << elapsed << " seconds" << endl;
timer.reset();
vector <string> output3 = longest_substring_trio(n_words);
elapsed = timer.elapsed();
cout << "longest_substring_trio, "
<< "n=" << n << ", "
<< "output=\"";
for (int i = 0; i < output3.size(); i++)
{
cout << output3[i];
}
cout << "\", "
<< "elapsed time=" << elapsed << " seconds" << endl;
system("pause");
return 0;
}