Below you will find pages that utilize the taxonomy term “Performance”
Posts
[Performance][C#]絕對值的取得
namespace WindowsFormsApplication35 { public partial class Form1 : Form { public Form1() { InitializeComponent(); }
static int ABS1(int value) { return value < 0 ? -value : value; } static int ABS2(int value) { return Math.Abs(value); } private void button1_Click(object sender, EventArgs e) { int count = (int)numericUpDown1.Value; int value = -1; textBox1.AppendText("Count: " + count.ToString() + Environment.NewLine); Stopwatch sw = Stopwatch.StartNew(); for (int idx = 0; idx < count; ++idx) ABS1(value); sw.
read morePosts
[Performance]Set Form's Position
Dim _f As New Form Private Sub btnSetByPoint_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetByPoint.Click _f.Show() Dim sw As Stopwatch = Stopwatch.StartNew For i As Integer = 0 To NumericUpDown1.Value _f.Location = New Point(10, 10) Next sw.Stop() _f.Hide() MsgBox("SetByPoint: " & sw.ElapsedMilliseconds.ToString) End Sub Private Sub btnSetByProperty_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetByProperty.Click _f.Show() Dim sw As Stopwatch = Stopwatch.StartNew For i As Integer = 0 To NumericUpDown1.
read morePosts
[Performance][C#]String.Empty V.S ldquo;rdquo;
Console.Clear(); int count = 1000000000; for (int idx = 0; idx < 3; ++idx) { EmptyString1(count); EmptyString2(count); EmptyString3(count); Console.WriteLine(); } } private static void EmptyString1(int count) { String test; Stopwatch sw = Stopwatch.StartNew(); for (int idx = 0; idx < count; ++idx) { test = ""; } sw.Stop(); Console.WriteLine("EmptyString1: " + sw.ElapsedMilliseconds.ToString()); } private static void EmptyString2(int count) { String test; Stopwatch sw = Stopwatch.StartNew(); for (int idx = 0; idx < count; ++idx) { test = string.
read morePosts
[Performance][C#]同時判斷多個字串是否為數值型態
sw.Reset(); sw.Start(); for (int idx = 0; idx < testCount; ++idx) { IsNumeric2_1(values); } sw.Stop(); Console.WriteLine("Method2-1: " + sw.ElapsedMilliseconds + " ms"); sw.Reset(); sw.Start(); for (int idx = 0; idx < testCount; ++idx) { IsNumeric2_2(values); } sw.Stop(); Console.WriteLine("Method2-2: " + sw.ElapsedMilliseconds + " ms"); sw.Reset(); sw.Start(); for (int idx = 0; idx < testCount; ++idx) { IsNumeric3(values); } sw.Stop(); Console.WriteLine("Method3: " + sw.ElapsedMilliseconds + " ms"); sw.Reset(); sw.Start(); for (int idx = 0; idx < testCount; ++idx) { IsNumeric4(values); } sw.
read morePosts
[Performance][C#]StringBuilder與String.Join串接字串時的效能比較
namespace ConsoleApplication17 { class Program { static void Main(string[] args) { int testTimes = 10; int dataCount = 1000000; GoTest(dataCount, testTimes); }
static void GoTest(int dataCount,int testTimes) { //Let JIT compiler precompiler Test1(1); Test2(1); //Test performance Stopwatch sw; long[] elapsedTimes = new long[testTimes]; Console.WriteLine("String.Join..."); for (int i = 0; i < testTimes; i++) { sw = Stopwatch.StartNew(); Test1(dataCount); elapsedTimes[i] = sw.ElapsedMilliseconds; Console.WriteLine("Elapsed Time: " + elapsedTimes[i]); } Console.WriteLine("Average Elapsed Time: " + elapsedTimes.
read morePosts
[Performance][C#]List V.S SortedList
<pre><span class="kwrd">using</span> System.Collections.Generic;</pre> <pre class="alt"><span class="kwrd">using</span> System.ComponentModel;</pre> <pre><span class="kwrd">using</span> System.Data;</pre> <pre class="alt"><span class="kwrd">using</span> System.Drawing;</pre> <pre><span class="kwrd">using</span> System.Linq;</pre> <pre class="alt"><span class="kwrd">using</span> System.Text;</pre> <pre><span class="kwrd">using</span> System.Windows.Forms;</pre> <pre class="alt"><span class="kwrd">using</span> System.Collections;</pre> <pre><span class="kwrd">using</span> System.Diagnostics;</pre> <pre class="alt"> </pre> <pre><span class="kwrd">namespace</span> HashTableVSSortedList</pre> <pre class="alt">{</pre> <pre> <span class="kwrd">public</span> <span class="kwrd">partial</span> <span class="kwrd">class</span> Form1 : Form</pre> <pre class="alt"> {</pre> <pre> <span class="kwrd">public</span> Form1()</pre> <pre class="alt"> {</pre> <pre> InitializeComponent();</pre> <pre class="alt"> }</pre> <pre> </pre> <pre class="alt"> <span class="kwrd">private</span> <span class="kwrd">void</span> button1_Click(<span class="kwrd">object</span> sender, EventArgs e)</pre> <pre> {</pre> <pre class="alt"> button1.
read morePosts
[Performance][VB.NET].NET空字串判斷徹底研究
.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, “Courier New”, courier, monospace; background-color: #ffffff; /white-space: pre;/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .
read morePosts
[Performance][VB.NET]If V.S IIf
<td valign="top" width="133">If</td> <td valign="top" width="133">IIf</td> </tr> <tr> <td valign="top" width="133">10000</td> <td valign="top" width="133">0 ms</td> <td valign="top" width="133">0 ms</td> </tr> <tr> <td valign="top" width="133">100000</td> <td valign="top" width="133">1 ms</td> <td valign="top" width="133">3 ms</td> </tr> <tr> <td valign="top" width="133">1000000</td> <td valign="top" width="133">10 ms</td> <td valign="top" width="133">32 ms</td> </tr> <tr> <td valign="top" width="133">10000000</td> <td valign="top" width="133">101 ms</td> <td valign="top" width="133">326 ms</td> </tr>
read more