I have a c++ code(A.cpp) in which i am openening a file and writting some data to it as follows :
A.cpp
classA{};
A::A()
{
_start = clock();
}
A::~A(){
_end = clock();
complete_time = _end - _start;
total_time = total_time + complete_time;
std::ofstream myfile;
myfile.open("C:/target/test.txt");
myfile << "a.cpp execution time "<<total_time;
}
So here i get a file as test.txt having the execution time. Now there is another class in which i am doing the same as follows (B.cpp):
classB{};
B::B()
{
_start = clock();
}
B::~B(){
_end = clock();
complete_time = _end - _start;
total_time = total_time + complete_time;
std::ofstream myfile;
myfile.open("C:/target/test.txt");
myfile << "B.cpp execution time "<<total_time;
}
Following is the main section:
int main(){
A ob;
B obj;
return 0;
}
So, now i get test.txt file as "a.cpp execution time 304" but there is no information regardging B.cpp execution time. so, please suggest how may i achieve this. I want to have a single test.txt file in which i get execution time of all of the classes of same solution, in the above solution there are only two classes there might be number of classes. So , please help.