This code block seems to get slower and slower...
The particle count is almost the same but the time the block took to run has increased massivly...(Emitter count is at 1 this whole time)
Time: 8267 Particle Count: 158
Time: 6433 Particle Count: 158
Time: 3245 Particle Count: 160
Time: 4901 Particle Count: 161
Time: 4994 Particle Count: 162
Time: 6719 Particle Count: 162
Time: 5007 Particle Count: 163
Time: 6643 Particle Count: 163
Time: 5055 Particle Count: 164
Time: 6689 Particle Count: 164
Time: 9049 Particle Count: 163
Time: 3054 Particle Count: 165
Time: 5491 Particle Count: 167
Time: 5110 Particle Count: 168
Time: 7179 Particle Count: 168
Time: 2978 Particle Count: 170
Time: 7143 Particle Count: 170
Time: 6925 Particle Count: 170
Time: 5325 Particle Count: 171
Time: 9280 Particle Count: 170
Time: 9105 Particle Count: 169
Time: 11169 Particle Count: 167
Time: 7453 Particle Count: 167
Time: 255117 Particle Count: 161
Time: 266118 Particle Count: 160
Time: 72346 Particle Count: 162
Time: 64797 Particle Count: 164
Time: 132198 Particle Count: 165
Time: 130426 Particle Count: 166
Time: 258557 Particle Count: 165
Time: 276580 Particle Count: 164
Time: 324695 Particle Count: 162
Time: 262078 Particle Count: 161
Time: 132970 Particle Count: 162
Time: 194183 Particle Count: 162
Time: 129831 Particle Count: 163
Time: 130800 Particle Count: 164
Time: 261817 Particle Count: 163
Time: 139235 Particle Count: 164
Time: 333496 Particle Count: 162
Time: 133433 Particle Count: 163
Time: 256135 Particle Count: 162
Time: 198325 Particle Count: 162
Time: 126966 Particle Count: 163
Time: 190183 Particle Count: 163
The offending block:
void c_system::update()
{
LARGE_INTEGER counter1, counter2;
QueryPerformanceCounter(&counter1);
for(std::vector<c_emitter*>::iterator it = emitter_list.begin(); it != emitter_list.end(); it++)
{
if((*it) == NULL) continue;
(*it)->update();
}
for(std::vector<c_part*>::iterator it = part_list.begin(); it != part_list.end(); it++)
{
if((*it) == NULL) continue;
(*it)->update();
}
QueryPerformanceCounter(&counter2);
cgm::log<< "Time: " << counter2.QuadPart - counter1.QuadPart << "\t Particle Count: " << count_part << "\n";
}
The particles are of type "class c_part_point : public c_part"
c_part_point::update()
void c_part_point::update()
{
age++;
speed += speed_change;
direction += direction_change;
x += lengthdir_x(speed, direction);
y += lengthdir_y(speed, direction);
if (life != -1 && age == life)
{
delete this;
return;
}
if(colour_fade) colour_fade_calc();
}
c_part::~c_part() -(c_part_point doesn't have it's own deconstructure)
c_part::~c_part()
{
for (std::vector<c_part*>::iterator it = owner_sys->part_list.begin(); it != owner_sys->part_list.end(); it++)
{
if ((*it)==this)
{
owner_sys->part_list.erase(it);
break;
}
}
count_part--;
}
Why would this get slower and slower? The entire code block (includeing the delete parts) are running from within the 1st 3 seconds yet it keeps slowing down untill it virtualy stops (takes about 15 min for it to get that bad)...