I have a huge code size. I recently added some new code and it works fine until I added a new simple if statement. After adding this add statement the runtime increases by 100X which is nonsense.
Some part of my code is below. The if statement is added in terminate_ongoing function and even if I remove everything inside if statement, the program is still slow. But if I comment this if statement, it becomes fast again.
The if statement is
if ( emitted_vulnerable_list.size() > 100000 ){
}
As you can see, I removed everything inside if, but the problem is not resolved. Could you please provide some hints to find the source of problem and solve it.
class flip_flop_vulnerable_time{
public:
list <vulnerable_time> emitted_vulnerable_list;
list <vulnerable_time> ongoing_vulnerable_list;
void terminate_ongoing(int PO, int minimum_delay , int cycle, long long elimination_time){
for (list<vulnerable_time>::iterator it=ongoing_vulnerable_list.begin(); it!=ongoing_vulnerable_list.end(); it++){
if ( it-> PO_signal_number == PO && it->cycles_passed == cycle && it->min_delay == minimum_delay ){
it-> elimination_time = elimination_time;
if ( cycle == 0 && elimination_time - it->appearance_time < 500 )
ongoing_vulnerable_list.erase(it);
else{
emitted_vulnerable_list.splice(emitted_vulnerable_list.end(),ongoing_vulnerable_list, it);
if ( emitted_vulnerable_list.size() > 100000 ){
}
}
return;
}
}
cout<<"\tError: can't find the following ongoing vulnerable_time object"<<endl;
exit(0);
}
// Some other functions here
};