VC7.1 STL Performance Problem

B

BCC

I am noticing what seems to be a huge drop in performance in STL from VC6.0
to VC7.1. Particularly
with vector.

The following code shows what I mean...

Any thoughts?

Thanks,
B

//Test the speed of operations on primitive arrays and vectors
#pragma warning(disable: 4786)

#include <vector>
#include <time.h>
#include <iostream>

using namespace std;

typedef vector<int> IntVec;

int main(int argc, char* argv[])
{
clock_t start, finish;
start = clock();
const int dim1 = 1000;
const int dim2 = 10000;

int* matrix[dim1];
for(int i = 0; i < dim1; i++)
{
matrix = new int[dim2];
for(int j = 0; j < dim2; j++)
matrix[j] = j;
}

finish = clock();
cout << "Total time taken for " << dim1 << "x" << dim2;
cout << " int array operations: ";
cout << double(finish-start) / CLOCKS_PER_SEC << " seconds" << endl;
for( i = 0; i < dim1; i++)
{
delete[] matrix;
}

start = clock();

vector<IntVec> intvecs(dim1);
for( i = 0; i < dim1; i++)
{
intvecs.resize(dim2);
for(int j = 0; j < dim2; j++)
intvecs[j] = j;
}

finish = clock();
cout << "Total time taken for " << dim1 << "x" << dim2;
cout << " int vector operations: ";
cout << double(finish-start) / CLOCKS_PER_SEC << " seconds" << endl;

return 0;
}

/**
*
==========================

output from VC6.0:

Total time taken for 1000x10000 int array operations: 0.12 seconds
Total time taken for 1000x10000 int vector operations: 0.14 seconds

==========================

output from VC7.1:

Total time taken for 1000x10000 int array operations: 0.12 seconds
Total time taken for 1000x10000 int vector operations: 1.231 seconds
==========================

*/
 
H

Hendrik Schober

BCC said:
I am noticing what seems to be a huge drop in performance in STL from VC6.0
to VC7.1. Particularly
with vector.

The following code shows what I mean...

Any thoughts?

I presume this is in release mode, with
optimizations applied?
Thanks,
B
[...]

Schobi

--
(e-mail address removed) is never read
I'm Schobi at suespammers dot org

"Sometimes compilers are so much more reasonable than people."
Scott Meyers
 
C

Carl Daniel [VC++ MVP]

BCC said:

Are you sure? I compiled your code with VC7.1 and got the following
results:

R:\>cl -O1 -EHs vectperf0227.cpp
Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 13.10.3077 for 80x86
Copyright (C) Microsoft Corporation 1984-2002. All rights reserved.

vectperf0227.cpp
Microsoft (R) Incremental Linker Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.

/out:vectperf0227.exe
vectperf0227.obj

R:\>vectperf0227
Total time taken for 1000x10000 int array operations: 0.093 seconds
Total time taken for 1000x10000 int vector operations: 0.094 seconds

R:\>

-cd
 
C

Carl Daniel [VC++ MVP]

BCC said:

You're not using Visual C++ .NET 2003 Standard Edition, are you? If so - no
optimizer, which would explain the performance difference.

-cd
 
B

BCC

Carl Daniel said:
You're not using Visual C++ .NET 2003 Standard Edition, are you? If so - no
optimizer, which would explain the performance difference.

-cd

Yikes! We are using that version. Nobody knew that this version has no
optimization available. Why the heck would microsoft do that? Well, I
guess $$ is the usual answer...

Thanks for the tip..

B
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top