Skip to content

Commit 14016d5

Browse files
author
ArthurHub
committed
* update demo app to run in .net 2.0
1 parent 53d193f commit 14016d5

4 files changed

Lines changed: 21 additions & 17 deletions

File tree

‎Source/Demo/DemoForm.Designer.cs‎

Lines changed: 0 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Source/Demo/DemoForm.cs‎

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -505,9 +505,10 @@ private void OnRunTestButtonClick(object sender, EventArgs e)
505505
Application.DoEvents();
506506

507507
GC.Collect();
508+
#if NET_40
508509
AppDomain.MonitoringIsEnabled = true;
509510
var startMemory = AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize;
510-
511+
#endif
511512
var sw = Stopwatch.StartNew();
512513

513514
const int iterations = 20;
@@ -522,10 +523,12 @@ private void OnRunTestButtonClick(object sender, EventArgs e)
522523

523524
sw.Stop();
524525

525-
526-
var endMemory = AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize;
527-
var totalMem = (endMemory - startMemory)/1024f;
528-
526+
long endMemory = 0;
527+
float totalMem = 0;
528+
#if NET_40
529+
endMemory = AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize;
530+
totalMem = (endMemory - startMemory)/1024f;
531+
#endif
529532
float htmlSize = 0;
530533
foreach (var sample in _perfTestSamples)
531534
htmlSize += sample.Length*2;

‎Source/Demo/HtmlRenderer.Demo.csproj‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>HtmlRenderer.Demo</RootNamespace>
1212
<AssemblyName>HtmlRendererDemo</AssemblyName>
13-
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
1414
<FileUpgradeFlags>
1515
</FileUpgradeFlags>
1616
<UpgradeBackupLocation>
@@ -31,14 +31,15 @@
3131
<IsWebBootstrapper>false</IsWebBootstrapper>
3232
<UseApplicationTrust>false</UseApplicationTrust>
3333
<BootstrapperEnabled>true</BootstrapperEnabled>
34-
<TargetFrameworkProfile>Client</TargetFrameworkProfile>
34+
<TargetFrameworkProfile>
35+
</TargetFrameworkProfile>
3536
</PropertyGroup>
3637
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
3738
<DebugSymbols>true</DebugSymbols>
3839
<DebugType>full</DebugType>
3940
<Optimize>false</Optimize>
4041
<OutputPath>bin\Debug\</OutputPath>
41-
<DefineConstants>DEBUG;TRACE</DefineConstants>
42+
<DefineConstants>TRACE;DEBUG</DefineConstants>
4243
<ErrorReport>prompt</ErrorReport>
4344
<WarningLevel>4</WarningLevel>
4445
<CodeAnalysisRuleSet>AllRules.ruleset</CodeAnalysisRuleSet>

‎Source/Demo/PerfForm.cs‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,10 @@ private void OnRunTestButtonClick(object sender, EventArgs e)
208208
var html = _samples[(string)_samplesTreeView.SelectedNode.Tag];
209209

210210
GC.Collect();
211+
#if NET_40
211212
AppDomain.MonitoringIsEnabled = true;
212213
var startMemory = AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize;
213-
214+
#endif
214215
var sw = Stopwatch.StartNew();
215216

216217
for (int i = 0; i < _iterations.Value; i++)
@@ -221,10 +222,13 @@ private void OnRunTestButtonClick(object sender, EventArgs e)
221222

222223
sw.Stop();
223224

224-
225-
var endMemory = AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize;
226-
var totalMem = (endMemory - startMemory) / 1024f;
227-
float htmlSize = html.Length*2/1024f;
225+
long endMemory = 0;
226+
float totalMem = 0;
227+
#if NET_40
228+
endMemory = AppDomain.CurrentDomain.MonitoringTotalAllocatedMemorySize;
229+
totalMem = (endMemory - startMemory) / 1024f;
230+
#endif
231+
float htmlSize = html.Length * 2 / 1024f;
228232

229233
var msg = string.Format("1 HTML ({0:N0} KB)\r\n{1} Iterations", htmlSize, _iterations.Value);
230234
msg += "\r\n\r\n";

0 commit comments

Comments
 (0)