B
Bala2508
Hi,
I have a C++ application that extensively uses std::string and
std:
stringstream in somewhat similar manner as below
std::string msgHeader;
msgHeader = "<";
msgHeader += a;
msgHeader += "><";
msgHeader += b;
msgHeader += "><";
msgHeader += c;
msgHeader += ">";
Similarly it uses ostringstream as well and the function that uses
this gets called almost on every message that my application gets on
the socket. I am using this to precisely construct a XML Message to
be sent to another application.
What we observed when we ran a collect/analyzer on the application is
that it shows majority of the CPU spent in trying to deal with these 2
datatypes, their memory allocation using std::allocator and other
stuff. The CPU goes as high as 100% sometimes.
I would like to get an advice/suggestion on the following points
1. Is there a better way to use std::string / std:
stringstream than
the way I have been using it?
2. AM I using the wrong datatype for such kind of operations and
should move on to use something else? Any suggestions what the
datatype should be?
I eventually need these datatypes because the external library that I
am using to send this data out needs it in std::string /
std:
stringstream formats.
Would like to have some suggestions to bring down the CPU utilization.
Thanks,
Bala
I have a C++ application that extensively uses std::string and
std:
std::string msgHeader;
msgHeader = "<";
msgHeader += a;
msgHeader += "><";
msgHeader += b;
msgHeader += "><";
msgHeader += c;
msgHeader += ">";
Similarly it uses ostringstream as well and the function that uses
this gets called almost on every message that my application gets on
the socket. I am using this to precisely construct a XML Message to
be sent to another application.
What we observed when we ran a collect/analyzer on the application is
that it shows majority of the CPU spent in trying to deal with these 2
datatypes, their memory allocation using std::allocator and other
stuff. The CPU goes as high as 100% sometimes.
I would like to get an advice/suggestion on the following points
1. Is there a better way to use std::string / std:
the way I have been using it?
2. AM I using the wrong datatype for such kind of operations and
should move on to use something else? Any suggestions what the
datatype should be?
I eventually need these datatypes because the external library that I
am using to send this data out needs it in std::string /
std:
Would like to have some suggestions to bring down the CPU utilization.
Thanks,
Bala