Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/corefx.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Mellino <erme@microsoft.com>2017-04-21 20:39:32 +0300
committerGitHub <noreply@github.com>2017-04-21 20:39:32 +0300
commite0c7181e3c675410b5f9e1ea819c9c5a6fb8c685 (patch)
tree6a90996b9fa9646aba1f33931c1919f26c282e66 /Documentation
parent93c476c4beac9b669686f023537c7a2aec5fe82e (diff)
Update code example and add extra bullet points.
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/project-docs/performance-tests.md7
1 files changed, 6 insertions, 1 deletions
diff --git a/Documentation/project-docs/performance-tests.md b/Documentation/project-docs/performance-tests.md
index fea2378306..0c59dea05c 100644
--- a/Documentation/project-docs/performance-tests.md
+++ b/Documentation/project-docs/performance-tests.md
@@ -77,6 +77,8 @@ namespace System.Collections.Tests
{
public class Perf_Dictionary
{
+ private volatile Dictionary<int, string> dict;
+
[Benchmark(InnerIterationCount = 2000)]
public void ctor()
{
@@ -84,7 +86,7 @@ namespace System.Collections.Tests
using (iteration.StartMeasurement())
for (int i = 0; i < Benchmark.InnerIterationCount; i++)
{
- new Dictionary<int, string>();
+ dict = new Dictionary<int, string>();
}
}
}
@@ -103,3 +105,6 @@ Test cases should adhere to the following guidelines, within reason:
* Pass intermediate values to a volatile static field. If the value is a struct, compute a value dependent on the structure, and store that in a volatile static field.
* Pass intermediate values to a no-inline method (`MethodImplOptions.NoInlining`)
* Conditionally store intermediate values to a field, where the condition is never true at runtime (but is still evaluated).
+* There are two main ways to detect when a test case is being "optimized out":
+ * Look at the disassembly of the function (with the Visual Studio disassembler, for example)
+ * Observe unusual changes in the duration metric. If your test suddenly takes 1% of its previous time, odds are something has gone wrong.