Click here to Skip to main content
15,906,766 members
Home / Discussions / C#
   

C#

 
GeneralRe: extended procedure for sql server Pin
Heath Stewart11-Nov-03 18:55
protectorHeath Stewart11-Nov-03 18:55 
GeneralRe: extended procedure for sql server Pin
Heath Stewart11-Nov-03 3:12
protectorHeath Stewart11-Nov-03 3:12 
GeneralRight to left problem Pin
Mohaqeq200211-Nov-03 0:41
sussMohaqeq200211-Nov-03 0:41 
GeneralRe: Right to left problem Pin
Heath Stewart11-Nov-03 3:19
protectorHeath Stewart11-Nov-03 3:19 
QuestionIs MS Access transaction-aware? Pin
CillyMe10-Nov-03 23:53
CillyMe10-Nov-03 23:53 
AnswerRe: Is MS Access transaction-aware? Pin
Hesham Amin11-Nov-03 0:41
Hesham Amin11-Nov-03 0:41 
GeneralRe: Is MS Access transaction-aware? Pin
CillyMe11-Nov-03 2:02
CillyMe11-Nov-03 2:02 
GeneralRe: Is MS Access transaction-aware? Pin
CillyMe11-Nov-03 2:50
CillyMe11-Nov-03 2:50 
GeneralRe: Is MS Access transaction-aware? Pin
Hesham Amin11-Nov-03 7:44
Hesham Amin11-Nov-03 7:44 
GeneralRe: Is MS Access transaction-aware? Pin
CillyMe11-Nov-03 16:47
CillyMe11-Nov-03 16:47 
GeneralBuilding Objects with Reflection Pin
Dennis Klein10-Nov-03 22:49
Dennis Klein10-Nov-03 22:49 
GeneralRe: Building Objects with Reflection Pin
Heath Stewart11-Nov-03 3:32
protectorHeath Stewart11-Nov-03 3:32 
GeneralRe: Building Objects with Reflection Pin
Dennis Klein11-Nov-03 22:12
Dennis Klein11-Nov-03 22:12 
GeneralRe: Building Objects with Reflection Pin
Heath Stewart12-Nov-03 2:39
protectorHeath Stewart12-Nov-03 2:39 
GeneralRe: Building Objects with Reflection Pin
Dennis Klein12-Nov-03 3:25
Dennis Klein12-Nov-03 3:25 
Generalcommunicate with service Pin
Member 67650610-Nov-03 22:45
Member 67650610-Nov-03 22:45 
GeneralRe: communicate with service Pin
Arjan Einbu10-Nov-03 23:03
Arjan Einbu10-Nov-03 23:03 
GeneralCOM+ application load balancing Pin
CillyMe10-Nov-03 20:34
CillyMe10-Nov-03 20:34 
GeneralLoading data to string variable Pin
Rostrox10-Nov-03 19:19
Rostrox10-Nov-03 19:19 
GeneralRe: Loading data to string variable Pin
Corinna John10-Nov-03 19:47
Corinna John10-Nov-03 19:47 
GeneralRe: Loading data to string variable Pin
Jeff Varszegi11-Nov-03 4:54
professionalJeff Varszegi11-Nov-03 4:54 
GeneralRe: Loading data to string variable Pin
Jeff Varszegi11-Nov-03 6:04
professionalJeff Varszegi11-Nov-03 6:04 
I was interested enough to run a performance test because I never used AppendFormat before, and I know that StringBuilder is highly optimized. I ran this code in Debug mode in VS .NET 2003 on my laptop:

C#
StringBuilder sb;
string text = "abc";
int x, y;
long startTime, endTime;
 <br>
startTime = DateTime.Now.Ticks;
for(y = 0; y < 5000; y++) {
    sb = new StringBuilder(10000);
    for (x = 0; x < 250; x++) {   
        sb.Append(text).Append('\n');
        sb.Append(text).Append('\n');
        sb.Append(text).Append('\n');
        sb.Append(text).Append('\n');
        sb.Append(text).Append('\n');
        sb.Append(text).Append('\n');
        sb.Append(text).Append('\n');
        sb.Append(text).Append('\n');
        sb.Append(text).Append('\n');
        sb.Append(text).Append('\n');
    }
}
endTime = DateTime.Now.Ticks;
Console.WriteLine(((endTime - startTime) / 10000) + " ms using Append()");
 <br>
startTime = DateTime.Now.Ticks;
for(y = 0; y < 5000; y++) {
    sb = new StringBuilder(10000);
    for (x = 0; x < 250; x++) {
        sb.AppendFormat("{0}\n", text);
        sb.AppendFormat("{0}\n", text);
        sb.AppendFormat("{0}\n", text);
        sb.AppendFormat("{0}\n", text);
        sb.AppendFormat("{0}\n", text);
        sb.AppendFormat("{0}\n", text);
        sb.AppendFormat("{0}\n", text);
        sb.AppendFormat("{0}\n", text);
        sb.AppendFormat("{0}\n", text);
        sb.AppendFormat("{0}\n", text);
    }
}
endTime = DateTime.Now.Ticks;
Console.WriteLine(((endTime - startTime) / 10000) + " ms using AppendFormat()");

It printed these results:
<font color="#000066">1682 ms using Append()</font>
<font color="#000066">7801 ms using AppendFormat()</font>

Interestingly enough, creating a separate variable to hold the format string and using that in calls to AppendFormat increased the run time of the second section a little. I still know next to nothing about the IL, but I'm sure there's some good explanation for this.

Regards,

Jeff Varszegi
GeneralControl/Class Existence Pin
Anonymous10-Nov-03 17:47
Anonymous10-Nov-03 17:47 
GeneralRe: Control/Class Existence Pin
Heath Stewart11-Nov-03 3:36
protectorHeath Stewart11-Nov-03 3:36 
GeneralRe: Control/Class Existence Pin
Bhangorix11-Nov-03 23:55
Bhangorix11-Nov-03 23:55 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.