Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
C++
Performance of hash_set vs. Java
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Alex Gerdemann, post: 1513939"] I'm using Cygwin's special version of GCC 3.3.3. I can't really seperate how much time is spent just reading the file, as I process it line by line, doing some work between each I/O call. Since you asked here's exactly what I did: std::vector< std::vector< std::string > > lines; std::string line; std::vector<std::string> thisLine; do { std::getline(file,line); if (line.length() != 0) { split(line,thisLine); lines.push_back(thisLine); //process the line } while(!netlist.eof()); inline void split(const std::string& line, std::vector<std::string>& words) { unsigned int firstMark = 0, lastMark = 0; words.clear(); while(lastMark!=std::string::npos) { firstMark=line.find_first_not_of(" ",lastMark); if(firstMark==std::string::npos) break; lastMark=line.find_first_of(" ",firstMark); words.push_back(line.substr(firstMark,lastMark-firstMark)); } } I added the reserve call which saved me a couple of tenths of a second. Nice, but must not be the major bottleneck. What is a "reference counted" class? I went ahead and tried this, but can't quite understand the results. The total time it computes is way off. (It says its 8s vs. the actual 14s). Also, it thinks that only 30% of run time was spent in the main() function. This can't possibly be right. -Alex Gerdemann University of Illinois Urbana-Champaign [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
C++
Performance of hash_set vs. Java
Top