foo + bar + x get resolved into Concat(foo, bar, x)
And that the jit treats stringbuilders specially in order to increase memory efficiency.
StringBuilder may not be quicker but its use will result in less memory consumption.
[1] http://www.codeproject.com/dotnet/strings.asp?target=%2Enet%7Cstrings
david, just to get clear, is this what you'd do instead? i've been wondering about the efficiency of Concat vs. Stringbuilder. do your benchmarks take garbage collection into account?
if ( this.Verbose ) {
string message = String.Concat( "SQL Task:", Environment.NewLine),
"Connection String: ", ConnectionString,
Environment.NewLine, "Use Transaction?: " , UseTransaction.ToString() ,
Environment.NewLine,
"Batch Sql Statements?: " , this.Batch.ToString() ,
Environment.NewLine,
"Batch Delimiter: " , this.Delimiter , Environment.NewLine,
"Delimiter Style: " , this.DelimiterStyle.ToString() ,
Environment.NewLine,
"Fail On Error?: " , this.FailOnError.ToString() ,
Environment.NewLine,
"Source script file: " , this.Source , Environment.NewLine,
"Output file: " , this.Output , Environment.NewLine );
Log(Level.Info, message );
}
/jean
-----Original Message-----
From: David Reed [mailto:[EMAIL PROTECTED] Sent: Wednesday, September 17, 2003 04:57
To: Ian MacLean
Cc: [EMAIL PROTECTED]
Subject: RE: [NAntC-Dev] SqlTask verbosity patch and mysterious usage of StringBuilder
Ian,
Unfortunately, no. But AppendFormat(...) does.
We don't use StringBuilder too much internally, because the consensus has been (despite what the fine manual says and all the fine MCTs teach) that it's not any faster than catting (we've run some 100k and 1M iteration tests that seem to indicate that it's actually slower for our typical string cat case) *and* more importantly it is less readable/maintainable than the comparable string cat cases in C#.
I'd love to see some code that I can run in-house that demonstrates the conventional wisdom about StringBuilder to be true, if anybody knows of some - that might restore some of my faith in humanity and/or our electoral process. :) Especially since my developer who was the most ardent anti-string builder campaigner has taken his soapbox elsewhere...
Since I'm already messing around in SqlTask, I'll change those errant, embedded cats inside Append() calls to use AppendFormat() and I'll resend the patch in a few hours.
-----Original Message-----mysterious usage
From: Ian MacLean [mailto:[EMAIL PROTECTED]
Sent: Tuesday, September 16, 2003 11:04 PM
To: David Reed
Cc: [EMAIL PROTECTED]
Subject: Re: [NAntC-Dev] SqlTask verbosity patch and
of
StringBuilderformatting syntax ?
David,
You're probably right. Does Append support the {1}
IanSqlTask to
Howdy'all, I'm working through the verbosity behavior in
usingmake it behave more like what I expected (please see the attached patch for your consideration) and I came across this additional oddity. Does it strike anybody else as defeating the purpose of
attachedStringBuilder in the first place? I didn't change it in the
be)patch, but it (although more readable that proper Append()s should
ConnectionStringhas Code Smell(r) to me. :)
Peoples' Exhibit 001a:
if ( this.Verbose ) {
StringBuilder message = new StringBuilder();
message.Append ("SQL Task:" + Environment.NewLine);
message.Append ("Connection String: " +
this.Delimiter ++ Environment.NewLine);
message.Append ("Use Transaction?: " + UseTransaction.ToString() + Environment.NewLine);
message.Append ("Batch Sql Statements?: " + this.Batch.ToString() + Environment.NewLine);
message.Append ("Batch Delimiter: " +
this.Source +Environment.NewLine);
message.Append ("Delimiter Style: " + this.DelimiterStyle.ToString() + Environment.NewLine);
message.Append ("Fail On Error?: " + this.FailOnError.ToString() + Environment.NewLine);
message.Append ("Source script file: " +
Environment.NewLine);
message.Append ("Output file: " + this.Output + Environment.NewLine);
Log(Level.Info, message.ToString());
}
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf _______________________________________________
NAntContrib-Developer mailing list [EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nantcontrib-developer
-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
NAntContrib-Developer mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nantcontrib-developer
------------------------------------------------------- This sf.net email is sponsored by:ThinkGeek Welcome to geek heaven. http://thinkgeek.com/sf _______________________________________________ NAntContrib-Developer mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/nantcontrib-developer