Skip to content

Commit 1bc15f5

Browse files
committed
添加StringBuilder的测试内存占用
1 parent 8897066 commit 1bc15f5

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

ProfilerSample1-1.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
using System;
2+
using System.Text;
3+
public class ProfilerSample1
4+
{
5+
static void Main (string[] args)
6+
{
7+
int start = Environment.TickCount;
8+
for (int i = 0; i < 1000; i++)
9+
{
10+
StringBuilder s = new StringBuilder();
11+
for (int j = 0; j < 100; j++)
12+
{
13+
s.Append("Outer index = ");
14+
s.Append(i);
15+
s.Append(" Inner index = ");
16+
s.Append(j);
17+
s.Append(" ");
18+
}
19+
}
20+
Console.WriteLine("Program ran for {0} seconds",
21+
0.001*(Environment.TickCount - start));
22+
}
23+
}

Readme

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ http://msdn.microsoft.com/zh-cn/library/ms979205
33

44
#csc bat
55
csc /t:exe /out:ProfilerSample1.exe ProfilerSample1.cs
6-
csc /t:exe /out:ProfilerSample2.exe ProfilerSample2.cs
6+
csc /t:exe /out:ProfilerSample2.exe ProfilerSample2.cs
7+
8+
csc /t:exe /out:ProfilerSample1.exe ProfilerSample1-1.cs

0 commit comments

Comments
 (0)