C
crea
How come STL library class is slower than normal C-code? I read from
somewhere that STL classes (vectors) are optmized for performance, so best
to use them. But I did a test and bitset failed.
I made a C-code and then the same with bitset class. C-code did the job in 2
seconds but bitset in 14 seconds. Quite a difference.
Really true that bitset -class is slow? I was thinking of using it , but I
need it to be very fast. If its this slow I cannot use it...
Code:
Test 1; C-version:
int n = 10001;
for(int i=0; i<1000000000;i++)
{
n |= i; // bit-or operation
}
Test 2; STL-version:
bitset<32> bi;
bitset<32> bi2;
for(int i=0; i<1000000000;i++)
{
bi |= bi2;
}
somewhere that STL classes (vectors) are optmized for performance, so best
to use them. But I did a test and bitset failed.
I made a C-code and then the same with bitset class. C-code did the job in 2
seconds but bitset in 14 seconds. Quite a difference.
Really true that bitset -class is slow? I was thinking of using it , but I
need it to be very fast. If its this slow I cannot use it...
Code:
Test 1; C-version:
int n = 10001;
for(int i=0; i<1000000000;i++)
{
n |= i; // bit-or operation
}
Test 2; STL-version:
bitset<32> bi;
bitset<32> bi2;
for(int i=0; i<1000000000;i++)
{
bi |= bi2;
}