public string LiteStringBuilder() { var m_strBuilder = new LiteStringBuilder(1); m_strBuilder.Append("PI=").Append(Math.PI).Append("_373=").Append(373).Append(true).Append(short.MaxValue).Append('z').Replace("373", "5428").Replace("St Paul", "HOT"); return(m_strBuilder.ToString()); }
private static string CustomCStringInstance() { var sb = new LiteStringBuilder(64); sb.Append("PI=").Append(Math.PI).Append("_373=").Append(373).Append(true).Append(short.MaxValue).Replace("373", "5428"); return(sb.ToString()); }
public string LiteStringBuilder() { LiteStringBuilder m_strCustom = new LiteStringBuilder(1); m_strCustom.Append("PI=").Append(Math.PI).Append("_373=").Append(373).Append(true).Append(short.MaxValue).Append('z').Replace("373", "5428"); return(m_strCustom.ToString()); }
static void Main(string[] args) { var fs = new LiteStringBuilder(); fs.Append("Hello World"); for (var a = 0; a < 50; a++) { var sw = Stopwatch.StartNew(); fs = new LiteStringBuilder(); for (var i = 0; i < 10000; i++) { fs.Append("Hello World"); } Console.WriteLine($"Test 1: {sw.Elapsed.TotalMilliseconds}"); //sw = Stopwatch.StartNew(); //fs = new LiteStringBuilder(); //for (var i = 0; i < 10000; i++) //{ // fs.AppendFast("Hello World"); //} //Console.WriteLine($"Test 2: {sw.Elapsed.TotalMilliseconds}"); var sb = new StringBuilder(32); sb.Append("Hello World"); sw = Stopwatch.StartNew(); sb = new StringBuilder(32); for (var i = 0; i < 10000; i++) { sb.Append("Hello World"); } Console.WriteLine($"Test 3: {sw.Elapsed.TotalMilliseconds}"); sw = Stopwatch.StartNew(); for (var i = 0; i < 10000; i++) { fs.ToString(); } Console.WriteLine($"Test 4: {sw.Elapsed.TotalMilliseconds}"); sw = Stopwatch.StartNew(); for (var i = 0; i < 10000; i++) { sb.ToString(); } Console.WriteLine($"Test 5: {sw.Elapsed.TotalMilliseconds}"); Console.WriteLine(); } // Console.WriteLine(fs.ToString()); Console.ReadLine(); }
public string Primative_LiteStringBuilder() { LiteStringBuilder m_strCustom = new LiteStringBuilder(64); // m_strCustom.Clear(); m_strCustom.Append(char.MaxValue).Append(Int16.MaxValue).Append(Int32.MaxValue).Append(Int64.MaxValue).Append(DateTime.MaxValue).Append(double.MaxValue).Append(float.MaxValue).Append(true).Append(byte.MaxValue).Append(sbyte.MaxValue); return(m_strCustom.ToString()); }
public string LargeArray_LiteStringBuilder() { LiteStringBuilder m_strCustom = new LiteStringBuilder(1); // m_strCustom.Clear(); m_strCustom.Append(_bigArray1).Append(_bigArray2).Append(_bigArray3); return(m_strCustom.ToString()); }
public string Large_LiteStringBuilder() { LiteStringBuilder m_strCustom = new LiteStringBuilder(1); // m_strCustom.Clear(); m_strCustom.Append(str1).Append(str2).Append(str3).Append(str4); return(m_strCustom.ToString()); }
private static string CustomCString() { m_strCustom.Clear(); m_strCustom.Append("PI=").Append(Math.PI).Append("_373=").Append(373).Append(true).Append(short.MaxValue).Replace("373", "5428"); return(m_strCustom.ToString()); }
static void Main(string[] args) { System.Threading.Thread.Sleep(1000); var fs = new LiteStringBuilder(); fs.Append((float)((float)60.0 / (float)7.0)); fs.Append("Hello World"); fs.ToString(); fs = null; PerfTest.RunTests(); Console.WriteLine("DOne"); Console.ReadLine(); for (var a = 0; a < 50; a++) { var sw = Stopwatch.StartNew(); fs = new LiteStringBuilder(); for (var i = 0; i < 10000; i++) { fs.Append("Hello World"); fs.Append(true); fs.Append(false); fs.Append(12345); fs.Append(int.MinValue); fs.Append(int.MaxValue); } Console.WriteLine($"Test 1: {sw.Elapsed.TotalMilliseconds}"); sw = Stopwatch.StartNew(); fs = new LiteStringBuilder(); for (var i = 0; i < 10000; i++) { fs.Append(true); fs.Append(false); fs.Append(int.MinValue); fs.Append(int.MaxValue); } Console.WriteLine($"Test 2: {sw.Elapsed.TotalMilliseconds}"); var sb = new StringBuilder(32); sb.Append("Hello World"); sw = Stopwatch.StartNew(); sb = new StringBuilder(32); for (var i = 0; i < 10000; i++) { sb.Append("Hello World"); sb.Append(true); sb.Append(false); sb.Append(int.MinValue); sb.Append(int.MaxValue); } Console.WriteLine($"Test 3: {sw.Elapsed.TotalMilliseconds}"); sw = Stopwatch.StartNew(); for (var i = 0; i < 10000; i++) { fs.ToString(); } Console.WriteLine($"Test 4: {sw.Elapsed.TotalMilliseconds}"); sw = Stopwatch.StartNew(); for (var i = 0; i < 10000; i++) { sb.ToString(); } Console.WriteLine($"Test 5: {sw.Elapsed.TotalMilliseconds}"); Console.WriteLine(); } // Console.WriteLine(fs.ToString()); Console.ReadLine(); }
static void Main(string[] args) { for (var i = 0; i < 10000; i++) { LargeArray_StringBuilder(); LargeArray_LiteStringBuilder(); } return; var fs = new LiteStringBuilder(1); //fs.Append(new string('a', 100)); //fs.Append((float)((float)60.0 / (float)7.0)); //fs.Append("Hello World"); //fs.ToString(); var l = new List <char>(); for (var i = 0; i < char.MaxValue; i++) { l.Add((char)i); } fs.Append(l.ToArray()); fs.Append(l.ToArray()); fs.Append(l.ToArray()); fs.Append(l.ToArray()); fs.Append(l.ToArray()); fs = null; PerfTest.RunTests(); Console.WriteLine("DOne"); Console.ReadLine(); for (var a = 0; a < 50; a++) { var sw = Stopwatch.StartNew(); fs = new LiteStringBuilder(); for (var i = 0; i < 10000; i++) { fs.Append("Hello World"); fs.Append(true); fs.Append(false); fs.Append(12345); fs.Append(int.MinValue); fs.Append(int.MaxValue); } Console.WriteLine($"Test 1: {sw.Elapsed.TotalMilliseconds}"); sw = Stopwatch.StartNew(); fs = new LiteStringBuilder(); for (var i = 0; i < 10000; i++) { fs.Append(true); fs.Append(false); fs.Append(int.MinValue); fs.Append(int.MaxValue); } Console.WriteLine($"Test 2: {sw.Elapsed.TotalMilliseconds}"); var sb = new StringBuilder(32); sb.Append("Hello World"); sw = Stopwatch.StartNew(); sb = new StringBuilder(32); for (var i = 0; i < 10000; i++) { sb.Append("Hello World"); sb.Append(true); sb.Append(false); sb.Append(int.MinValue); sb.Append(int.MaxValue); } Console.WriteLine($"Test 3: {sw.Elapsed.TotalMilliseconds}"); sw = Stopwatch.StartNew(); for (var i = 0; i < 10000; i++) { fs.ToString(); } Console.WriteLine($"Test 4: {sw.Elapsed.TotalMilliseconds}"); sw = Stopwatch.StartNew(); for (var i = 0; i < 10000; i++) { sb.ToString(); } Console.WriteLine($"Test 5: {sw.Elapsed.TotalMilliseconds}"); Console.WriteLine(); } // Console.WriteLine(fs.ToString()); Console.ReadLine(); }