Issue Details (XML | Word | Printable)

Key: STDCXX-231
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Travis Vitek
Reporter: Martin Sebor
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

std::getline from <string> header is rather slow

Created: 29/Jun/06 01:39 AM   Updated: 04/Feb/08 10:42 PM
Return to search
Component/s: 21. Strings
Affects Version/s: 4.1.2, 4.1.3, 4.1.4, 4.2.0
Fix Version/s: 4.2.1

Time Tracking:
Original Estimate: 4h
Original Estimate - 4h
Remaining Estimate: 0.5h
Time Spent - 7.5h Remaining Estimate - 0.5h
Time Spent: 7.5h
Time Spent - 7.5h Remaining Estimate - 0.5h

File Attachments:
  Size
Text File Licensed for inclusion in ASF works stdcxx-231.patch 2008-01-30 01:49 AM Travis Vitek 1 kB

Severity: Inefficiency
Resolution Date: 04/Feb/08 10:42 PM


 Description  « Hide
Moved from the Rogue Wave bug tracking database:
****Created By: leroy @ Jan 25, 2001 03:20:01 PM****


Environment
  Compiler : SUNPRO 4.2
  OS : Solaris 2.5.1
  SCL : 1.3.0 (Summer-1999)
  Tools : 7.1.0 (Summer-1999) --> Use only for RWBench

Command line option :
  for debug : 
  CC -xildoff +w +p -g -o Test_dbg.exe test.cc -DRWDEBUG=1 \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/include \
-I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/lib -Bstatic -ltls11s -lstd11s -Bdynamic

  for release :
CC -xildoff +w +p -fast -o Test_release.exe test.cc \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/include \
-I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/lib -Bstatic -ltls8s -lstd8s -Bdynamic
 (Uploaded file: 997149-test.cc)
                                                                     
**** Entered By: Web @ Thursday, January 25, 2001 2:41:42 AM **** 
Location of uploaded file: 
http://thoth.bco.roguewave.com/uploads/997149-test.cc

View all uploaded files for this incident: 
http://webdev.roguewave.com/admin/tsvw/index.cfm?IncidentID=997149

**** Entered By: Web @ Thursday, January 25, 2001 2:44:56 AM **** 
#web
Please find my test case at the end of the note

Environment
  Compiler : SUNPRO 4.2
  OS : Solaris 2.5.1
  SCL : 1.3.0 (Summer-1999)
  Tools : 7.1.0 (Summer-1999) --> Use only for RWBench

Command line option :
  for debug : 
  CC -xildoff +w +p -g -o Test_dbg.exe test.cc -DRWDEBUG=1 \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/include \
-I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/lib -Bstatic -ltls11s -lstd11s -Bdynamic

  for release :
CC -xildoff +w +p -fast -o Test_release.exe test.cc \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s 
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/include \
-I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/lib -Bstatic -ltls8s -lstd8s -Bdynamic

#Code
#include <string>
#include <fstream.h>
#include <iostream.h>
#include <rw/bench.h>
 
 
class std_string_getline : public RWBench
{
  public:
   std_string_getline() {;}
 
   void doLoop(unsigned long n);
   void idleLoop(unsigned long n);
   void what(ostream& os) const { os << "Standard String Getline : " << endl;}
};
 
class classic_getline : public RWBench
{
  public:
    classic_getline() {;}
 
    void doLoop(unsigned long n);
    void idleLoop(unsigned long n);
    void what(ostream& os) const { os << "Classic Getline : " << endl;}
};
 
int
main(int argc, char** argv)
{
 
  std_string_getline test_std_string;
  test_std_string.parse(argc, argv);
  test_std_string.go();
  test_std_string.report(cout);
 
  classic_getline test_classic_getline;
  test_classic_getline.parse(argc, argv);
  test_classic_getline.go();
  test_classic_getline.report(cout);
}
 
void
std_string_getline::doLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    string line;
    line.reserve(512);
 
    while (!(toRead.eof()))
    {
      getline(toRead, line, '\n');
    }
  }
}
 
void
std_string_getline::idleLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    string line;
    line.reserve(512);
  }
}
 
void
classic_getline::doLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    char cLine[512];
    string line;
    line.reserve(512);
 
    while (!(toRead.eof()))
    {
      toRead.getline(cLine, 512);
      line = cLine;
    }
  }
}
 
void
classic_getline::idleLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    char cLine[512];
    string line;
    line.reserve(512);
  }
}

#EndCode                

There appears to be something to this.  I ran the program and here is the output:

Sun C++ 

Standard String Getline : 

Iterations:                 1
Inner loop operations:      1000
Total operations:           1000
Elapsed (user) time:        18.18
Operations per second:      55.0055

Sun C++ 

Classic Getline : 

Iterations:                 5
Inner loop operations:      1000
Total operations:           5000
Elapsed (user) time:        4.67
Kilo-operations per second: 1.07066


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Martin Sebor made changes - 10/Dec/07 07:06 AM
Field Original Value New Value
Affects Version/s 4.1.2 [ 12310173 ]
Severity Inefficiency
Affects Version/s 4.1.4 [ 12310693 ]
Affects Version/s 4.2.0 [ 12311945 ]
Affects Version/s 4.1.3 [ 12310191 ]
Fix Version/s 4.2.1 [ 12312690 ]
Travis Vitek made changes - 15/Jan/08 07:47 PM
Assignee Travis Vitek [ vitek ]
Travis Vitek made changes - 30/Jan/08 01:49 AM
Attachment stdcxx-231.patch [ 12374323 ]
Travis Vitek made changes - 30/Jan/08 01:51 AM
Remaining Estimate 4h [ 14400 ]
Original Estimate 4h [ 14400 ]
Travis Vitek made changes - 30/Jan/08 01:53 AM
Time Spent 4h [ 14400 ]
Martin Sebor made changes - 30/Jan/08 02:40 AM
Description Moved from the Rogue Wave bug tracking database:

****Created By: leroy @ Jan 25, 2001 03:20:01 PM****


Environment
  Compiler : SUNPRO 4.2
  OS : Solaris 2.5.1
  SCL : 1.3.0 (Summer-1999)
  Tools : 7.1.0 (Summer-1999) --> Use only for RWBench

Command line option :
  for debug :
  CC -xildoff +w +p -g -o Test_dbg.exe test.cc -DRWDEBUG=1 -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/lib -Bstatic -ltls11s -lstd11s -Bdynamic

  for release :
CC -xildoff +w +p -fast -o Test_release.exe test.cc -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/lib -Bstatic -ltls8s -lstd8s -Bdynamic
 (Uploaded file: 997149-test.cc)
**** Entered By: Web @ Thursday, January 25, 2001 2:41:42 AM ****
Location of uploaded file:
http://thoth.bco.roguewave.com/uploads/997149-test.cc

View all uploaded files for this incident:
http://webdev.roguewave.com/admin/tsvw/index.cfm?IncidentID=997149
**** Entered By: Web @ Thursday, January 25, 2001 2:44:56 AM ****
#web
Please find my test case at the end of the note

Environment
  Compiler : SUNPRO 4.2
  OS : Solaris 2.5.1
  SCL : 1.3.0 (Summer-1999)
  Tools : 7.1.0 (Summer-1999) --> Use only for RWBench

Command line option :
  for debug :
  CC -xildoff +w +p -g -o Test_dbg.exe test.cc -DRWDEBUG=1 -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/lib -Bstatic -ltls11s -lstd11s -Bdynamic

  for release :
CC -xildoff +w +p -fast -o Test_release.exe test.cc -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/lib -Bstatic -ltls8s -lstd8s -Bdynamic

#Code
#include <string>
#include <fstream.h>
#include <iostream.h>
#include <rw/bench.h>
 
 
class std_string_getline : public RWBench
{
  public:
   std_string_getline() {;}
 
   void doLoop(unsigned long n);
   void idleLoop(unsigned long n);
   void what(ostream& os) const { os << "Standard String Getline : " << endl;}
};
 
class classic_getline : public RWBench
{
  public:
    classic_getline() {;}
 
    void doLoop(unsigned long n);
    void idleLoop(unsigned long n);
    void what(ostream& os) const { os << "Classic Getline : " << endl;}
};
 
int
main(int argc, char** argv)
{
 
  std_string_getline test_std_string;
  test_std_string.parse(argc, argv);
  test_std_string.go();
  test_std_string.report(cout);
 
  classic_getline test_classic_getline;
  test_classic_getline.parse(argc, argv);
  test_classic_getline.go();
  test_classic_getline.report(cout);
}
 
void
std_string_getline::doLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    string line;
    line.reserve(512);
 
    while (!(toRead.eof()))
    {
      getline(toRead, line, '\n');
    }
  }
}
 
void
std_string_getline::idleLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    string line;
    line.reserve(512);
  }
}
 
void
classic_getline::doLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    char cLine[512];
    string line;
    line.reserve(512);
 
    while (!(toRead.eof()))
    {
      toRead.getline(cLine, 512);
      line = cLine;
    }
  }
}
 
void
classic_getline::idleLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    char cLine[512];
    string line;
    line.reserve(512);
  }
}

#EndCode

There appears to be something to this. I ran the program and here is the output:

Sun C++

Standard String Getline :

Iterations: 1
Inner loop operations: 1000
Total operations: 1000
Elapsed (user) time: 18.18
Operations per second: 55.0055

Sun C++

Classic Getline :

Iterations: 5
Inner loop operations: 1000
Total operations: 5000
Elapsed (user) time: 4.67
Kilo-operations per second: 1.07066
Moved from the Rogue Wave bug tracking database:

{noformat}
****Created By: leroy @ Jan 25, 2001 03:20:01 PM****


Environment
  Compiler : SUNPRO 4.2
  OS : Solaris 2.5.1
  SCL : 1.3.0 (Summer-1999)
  Tools : 7.1.0 (Summer-1999) --> Use only for RWBench

Command line option :
  for debug :
  CC -xildoff +w +p -g -o Test_dbg.exe test.cc -DRWDEBUG=1 -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/lib -Bstatic -ltls11s -lstd11s -Bdynamic

  for release :
CC -xildoff +w +p -fast -o Test_release.exe test.cc -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/lib -Bstatic -ltls8s -lstd8s -Bdynamic
 (Uploaded file: 997149-test.cc)
**** Entered By: Web @ Thursday, January 25, 2001 2:41:42 AM ****
Location of uploaded file:
http://thoth.bco.roguewave.com/uploads/997149-test.cc

View all uploaded files for this incident:
http://webdev.roguewave.com/admin/tsvw/index.cfm?IncidentID=997149
**** Entered By: Web @ Thursday, January 25, 2001 2:44:56 AM ****
#web
Please find my test case at the end of the note

Environment
  Compiler : SUNPRO 4.2
  OS : Solaris 2.5.1
  SCL : 1.3.0 (Summer-1999)
  Tools : 7.1.0 (Summer-1999) --> Use only for RWBench

Command line option :
  for debug :
  CC -xildoff +w +p -g -o Test_dbg.exe test.cc -DRWDEBUG=1 -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/lib -Bstatic -ltls11s -lstd11s -Bdynamic

  for release :
CC -xildoff +w +p -fast -o Test_release.exe test.cc -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/lib -Bstatic -ltls8s -lstd8s -Bdynamic

#Code
#include <string>
#include <fstream.h>
#include <iostream.h>
#include <rw/bench.h>
 
 
class std_string_getline : public RWBench
{
  public:
   std_string_getline() {;}
 
   void doLoop(unsigned long n);
   void idleLoop(unsigned long n);
   void what(ostream& os) const { os << "Standard String Getline : " << endl;}
};
 
class classic_getline : public RWBench
{
  public:
    classic_getline() {;}
 
    void doLoop(unsigned long n);
    void idleLoop(unsigned long n);
    void what(ostream& os) const { os << "Classic Getline : " << endl;}
};
 
int
main(int argc, char** argv)
{
 
  std_string_getline test_std_string;
  test_std_string.parse(argc, argv);
  test_std_string.go();
  test_std_string.report(cout);
 
  classic_getline test_classic_getline;
  test_classic_getline.parse(argc, argv);
  test_classic_getline.go();
  test_classic_getline.report(cout);
}
 
void
std_string_getline::doLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    string line;
    line.reserve(512);
 
    while (!(toRead.eof()))
    {
      getline(toRead, line, '\n');
    }
  }
}
 
void
std_string_getline::idleLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    string line;
    line.reserve(512);
  }
}
 
void
classic_getline::doLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    char cLine[512];
    string line;
    line.reserve(512);
 
    while (!(toRead.eof()))
    {
      toRead.getline(cLine, 512);
      line = cLine;
    }
  }
}
 
void
classic_getline::idleLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    char cLine[512];
    string line;
    line.reserve(512);
  }
}

#EndCode

There appears to be something to this. I ran the program and here is the output:

Sun C++

Standard String Getline :

Iterations: 1
Inner loop operations: 1000
Total operations: 1000
Elapsed (user) time: 18.18
Operations per second: 55.0055

Sun C++

Classic Getline :

Iterations: 5
Inner loop operations: 1000
Total operations: 5000
Elapsed (user) time: 4.67
Kilo-operations per second: 1.07066
{noformat}
Travis Vitek made changes - 30/Jan/08 08:46 AM
Description Moved from the Rogue Wave bug tracking database:

{noformat}
****Created By: leroy @ Jan 25, 2001 03:20:01 PM****


Environment
  Compiler : SUNPRO 4.2
  OS : Solaris 2.5.1
  SCL : 1.3.0 (Summer-1999)
  Tools : 7.1.0 (Summer-1999) --> Use only for RWBench

Command line option :
  for debug :
  CC -xildoff +w +p -g -o Test_dbg.exe test.cc -DRWDEBUG=1 -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/lib -Bstatic -ltls11s -lstd11s -Bdynamic

  for release :
CC -xildoff +w +p -fast -o Test_release.exe test.cc -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/lib -Bstatic -ltls8s -lstd8s -Bdynamic
 (Uploaded file: 997149-test.cc)
**** Entered By: Web @ Thursday, January 25, 2001 2:41:42 AM ****
Location of uploaded file:
http://thoth.bco.roguewave.com/uploads/997149-test.cc

View all uploaded files for this incident:
http://webdev.roguewave.com/admin/tsvw/index.cfm?IncidentID=997149
**** Entered By: Web @ Thursday, January 25, 2001 2:44:56 AM ****
#web
Please find my test case at the end of the note

Environment
  Compiler : SUNPRO 4.2
  OS : Solaris 2.5.1
  SCL : 1.3.0 (Summer-1999)
  Tools : 7.1.0 (Summer-1999) --> Use only for RWBench

Command line option :
  for debug :
  CC -xildoff +w +p -g -o Test_dbg.exe test.cc -DRWDEBUG=1 -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/lib -Bstatic -ltls11s -lstd11s -Bdynamic

  for release :
CC -xildoff +w +p -fast -o Test_release.exe test.cc -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s -I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/include -I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/lib -Bstatic -ltls8s -lstd8s -Bdynamic

#Code
#include <string>
#include <fstream.h>
#include <iostream.h>
#include <rw/bench.h>
 
 
class std_string_getline : public RWBench
{
  public:
   std_string_getline() {;}
 
   void doLoop(unsigned long n);
   void idleLoop(unsigned long n);
   void what(ostream& os) const { os << "Standard String Getline : " << endl;}
};
 
class classic_getline : public RWBench
{
  public:
    classic_getline() {;}
 
    void doLoop(unsigned long n);
    void idleLoop(unsigned long n);
    void what(ostream& os) const { os << "Classic Getline : " << endl;}
};
 
int
main(int argc, char** argv)
{
 
  std_string_getline test_std_string;
  test_std_string.parse(argc, argv);
  test_std_string.go();
  test_std_string.report(cout);
 
  classic_getline test_classic_getline;
  test_classic_getline.parse(argc, argv);
  test_classic_getline.go();
  test_classic_getline.report(cout);
}
 
void
std_string_getline::doLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    string line;
    line.reserve(512);
 
    while (!(toRead.eof()))
    {
      getline(toRead, line, '\n');
    }
  }
}
 
void
std_string_getline::idleLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    string line;
    line.reserve(512);
  }
}
 
void
classic_getline::doLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    char cLine[512];
    string line;
    line.reserve(512);
 
    while (!(toRead.eof()))
    {
      toRead.getline(cLine, 512);
      line = cLine;
    }
  }
}
 
void
classic_getline::idleLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    char cLine[512];
    string line;
    line.reserve(512);
  }
}

#EndCode

There appears to be something to this. I ran the program and here is the output:

Sun C++

Standard String Getline :

Iterations: 1
Inner loop operations: 1000
Total operations: 1000
Elapsed (user) time: 18.18
Operations per second: 55.0055

Sun C++

Classic Getline :

Iterations: 5
Inner loop operations: 1000
Total operations: 5000
Elapsed (user) time: 4.67
Kilo-operations per second: 1.07066
{noformat}
Moved from the Rogue Wave bug tracking database:

{noformat}
****Created By: leroy @ Jan 25, 2001 03:20:01 PM****


Environment
  Compiler : SUNPRO 4.2
  OS : Solaris 2.5.1
  SCL : 1.3.0 (Summer-1999)
  Tools : 7.1.0 (Summer-1999) --> Use only for RWBench

Command line option :
  for debug :
  CC -xildoff +w +p -g -o Test_dbg.exe test.cc -DRWDEBUG=1 \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/include \
-I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/lib -Bstatic -ltls11s -lstd11s -Bdynamic

  for release :
CC -xildoff +w +p -fast -o Test_release.exe test.cc \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/include \
-I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/lib -Bstatic -ltls8s -lstd8s -Bdynamic
 (Uploaded file: 997149-test.cc)
                                                                     
**** Entered By: Web @ Thursday, January 25, 2001 2:41:42 AM ****
Location of uploaded file:
http://thoth.bco.roguewave.com/uploads/997149-test.cc

View all uploaded files for this incident:
http://webdev.roguewave.com/admin/tsvw/index.cfm?IncidentID=997149

**** Entered By: Web @ Thursday, January 25, 2001 2:44:56 AM ****
#web
Please find my test case at the end of the note

Environment
  Compiler : SUNPRO 4.2
  OS : Solaris 2.5.1
  SCL : 1.3.0 (Summer-1999)
  Tools : 7.1.0 (Summer-1999) --> Use only for RWBench

Command line option :
  for debug :
  CC -xildoff +w +p -g -o Test_dbg.exe test.cc -DRWDEBUG=1 \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/include \
-I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/11s/lib -Bstatic -ltls11s -lstd11s -Bdynamic

  for release :
CC -xildoff +w +p -fast -o Test_release.exe test.cc \
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s
-I/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/include \
-I. -L/opt/RogueWave/Summer-1999/workspaces/SOLARIS251/SUNPRO42/8s/lib -Bstatic -ltls8s -lstd8s -Bdynamic

#Code
#include <string>
#include <fstream.h>
#include <iostream.h>
#include <rw/bench.h>
 
 
class std_string_getline : public RWBench
{
  public:
   std_string_getline() {;}
 
   void doLoop(unsigned long n);
   void idleLoop(unsigned long n);
   void what(ostream& os) const { os << "Standard String Getline : " << endl;}
};
 
class classic_getline : public RWBench
{
  public:
    classic_getline() {;}
 
    void doLoop(unsigned long n);
    void idleLoop(unsigned long n);
    void what(ostream& os) const { os << "Classic Getline : " << endl;}
};
 
int
main(int argc, char** argv)
{
 
  std_string_getline test_std_string;
  test_std_string.parse(argc, argv);
  test_std_string.go();
  test_std_string.report(cout);
 
  classic_getline test_classic_getline;
  test_classic_getline.parse(argc, argv);
  test_classic_getline.go();
  test_classic_getline.report(cout);
}
 
void
std_string_getline::doLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    string line;
    line.reserve(512);
 
    while (!(toRead.eof()))
    {
      getline(toRead, line, '\n');
    }
  }
}
 
void
std_string_getline::idleLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    string line;
    line.reserve(512);
  }
}
 
void
classic_getline::doLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    char cLine[512];
    string line;
    line.reserve(512);
 
    while (!(toRead.eof()))
    {
      toRead.getline(cLine, 512);
      line = cLine;
    }
  }
}
 
void
classic_getline::idleLoop(unsigned long n)
{
  while (n--)
  {
    ifstream toRead(__FILE__);
    char cLine[512];
    string line;
    line.reserve(512);
  }
}

#EndCode

There appears to be something to this. I ran the program and here is the output:

Sun C++

Standard String Getline :

Iterations: 1
Inner loop operations: 1000
Total operations: 1000
Elapsed (user) time: 18.18
Operations per second: 55.0055

Sun C++

Classic Getline :

Iterations: 5
Inner loop operations: 1000
Total operations: 5000
Elapsed (user) time: 4.67
Kilo-operations per second: 1.07066
{noformat}
Travis Vitek made changes - 30/Jan/08 08:47 AM
Time Spent 4h [ 14400 ] 5h [ 18000 ]
Remaining Estimate 4h [ 14400 ] 3h [ 10800 ]
Travis Vitek made changes - 31/Jan/08 09:22 PM
Time Spent 5h [ 18000 ] 5.5h [ 19800 ]
Remaining Estimate 3h [ 10800 ] 2.5h [ 9000 ]
Travis Vitek made changes - 31/Jan/08 11:02 PM
Time Spent 5.5h [ 19800 ] 7.5h [ 27000 ]
Remaining Estimate 2.5h [ 9000 ] 0.5h [ 1800 ]
Travis Vitek made changes - 04/Feb/08 10:42 PM
Resolution Fixed [ 1 ]
Status Open [ 1 ] Resolved [ 5 ]
Travis Vitek made changes - 04/Feb/08 10:42 PM
Status Resolved [ 5 ] Closed [ 6 ]