This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/13351] New: 10x slower execution speed GCC 3.3 (compared with GCC 3.2)


The execution speed of the following simple program is 10x slower on GCC 3.3 
than on GCC 3.2 (using cygwin; I haven't tested Linux yet).  To reproduce, 
save it and compile with:
  g++ -Wall -pedantic -O -DNDEBUG speedtest2.cpp

========================================================================
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <sys/types.h>
#include <sys/timeb.h>

inline
double timeToMillisec()
{
  timeb x;    // Change to _timeb with MSVC++
  ftime(&x);  // Change to _ftime with MSVC++
  return double(x.time) + double(x.millitm)/1000.0;
}

typedef std::string           String;
typedef std::vector<String>   List;
typedef std::map<String,List> Map;

List foo(unsigned numEntries)
{
  List v;
  for (unsigned i = 0u; i < numEntries; ++i)
    v.push_back(String("foo") + char(i % 256));
  return v;
}

Map bar(unsigned numEntries, List v)
{
  Map m;
  for (unsigned i = 0u; i < numEntries; ++i)
    m[String("foo") + char(i % 256)] = v;
  return m;
}

int main()
{
  const unsigned perIteration = 1000u;

  std::cout << "Testing: " << std::flush;
  const double begin = timeToMillisec();
  double elapsed;
  unsigned total = 0u;

  do {
    bar(perIteration, foo(perIteration));
    total += perIteration * perIteration;
    elapsed = timeToMillisec() - begin;
  } while (elapsed < 1.0);

  std::cout << total << " in " << elapsed << " sec = "
            << (elapsed * 1000.0 * 1000.0 / total) << " ns/per\n";

  return 0;
}
========================================================================

-- 
           Summary: 10x slower execution speed GCC 3.3 (compared with GCC
                    3.2)
           Product: gcc
           Version: 3.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: cline at parashift dot com
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13351


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]