Trying to determine how long it takes to run program using some time function

My program uses a hash to find matches between two files. My problem is that i need to figure out how long it takes the program to find these matches. i need to use some sort of time function or something to do this but im not sure what to do. If anyone could help that would be awesome because this is due in a few hours.

#include <iostream>
#include <string>
#include <fstream>
#include <ctime>


using namespace std;

unsigned int RSHash( string &str );
void matchingwords(int count,int countnew, unsigned int* hash, unsigned int* B,string *A);


int main()
{

//intro
cout << "Welcome to MIDN Combado's project #2" << endl;
cout << endl;

int count=0,countnew=0;
string words;

//open dictionary file
ifstream fin("wordbank4.txt");

//count how many words are in file
while(!fin.eof()){

fin >> words;
count++;
}

//close file
fin.close();



//open file step2.txt
ifstream fin2("password.txt");

//count how many words are in file step2.txt
while(!fin2.eof()) {
fin2 >> words;
countnew++;
}
//close file
fin2.close();


//re-open dictionary
fin.open("wordbank4.txt");
string str;

//create array A and read strings from file
unsigned int *hash;
hash = new unsigned int [count];
string *A= new string[count];

for(int i=0;i<count;i++) {
fin >> A[i];
hash[i] = RSHash(A[i]);
}


//re-open step2 file
fin2.open("password.txt");

//create array B and read strings from file
unsigned int *B=new unsigned int[countnew];

for(int j=0;j<countnew;j++) {
fin2 >> B[j];
}



//call on function
matchingwords(count, countnew,hash,B,A);

cout << endl;



return 0;
}

//-------------------------------------------------------
unsigned int RSHash( string &str ) {
unsigned int b = 378551;
unsigned int a = 63689;
unsigned int hash = 0;

for( int i = 0; i < str.length(); i++ ) {
hash = hash * a + str[i];
a = a * b;
}

return hash;
}

void matchingwords(int count,int countnew, unsigned int* hash, unsigned int* B,string *A)
{
int match=0;


for(int i=0;i<count;i++) {

for(int j=0;j<countnew;j++) {

if(B[j] == hash[i]) {



cout << hash[i] << " matches with " << A[i] << endl;


}



}
}

}



It all depends on the best timer resolution available to you. You'll have to run your algorithm in a loop to scale it up to your timer.

Records the time, run your algorithm, say, a million times in loop then record the stop time.
Here are some useful timer functions for you:
http://www.cplusplus.com/forum/beginner/28855/page3.html#msg159698
That reminded me about this link of links:
http://www.cplusplus.com/forum/windows/23401/
Topic archived. No new replies allowed.