Hi,
My query is not concerning valgrind although I have used the tool to
investigate it. I am trying to understand why the code (snippet) in
listing (a) is markedly slower (on modern cpu) than the code in listing
(b). (The two programs are intended to be functionally equivalent.)
My initial hypothesis was conditional branch misses in the former but it
doesn't seem to be the case.
Any ideas?
Many thanks!
stan
Listing (a)
============
char* sep = ",";
for (i = 0; i < len; i++) {
sprintf(tmp, "%d", i);
buf = strcat(buf, tmp);
if (i != len-1) {
strcat(buf, sep);
}
}
Listing (b)
===========
char* sep = "";
for (i = 0; i < len; i++) {
strcat(buf, sep);
sprintf(tmp, "%d", i);
buf = strcat(buf, tmp);
sep = ",";
}
------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure
contains a definitive record of customers, application performance,
security threats, fraudulent activity, and more. Splunk takes this
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Valgrind-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/valgrind-users