I come across a behavior in STL queue push which I don't quite understand.
Basically, I have two struct
structA{
string a;
}
structB{
char b[256];
}
structA st1;
structB st2;
...assign a 256 characters string to both st1 and st2...
queue<structA> q1;
queue<structB> q2;
for(int i=0 ; i< 10000; i++){
q1.push(st1);
}
for(int i=0 ; i< 10000; i++){
q2.push(st2);
}
What I realize is that the queue using the char struct would use a much longer time (like 5X) in pushing the struct compared to string struct. Upon examination of the individual push, I realize that the char struct push performance has quite a number of spikes (range from 2X to 10X) here and there. What is the reason for that?
Thanks.