Add assert when dllmap is disabled and fix support build in netcore mode
[mono-project.git] / mono / tests / gc-graystack-stress.cs
blob79743cd249664beb3986a257c37cdf06d5445ba8
1 using System;
2 using System.Collections.Generic;
3 using System.Diagnostics;
5 class Program {
7 class Node {
8 Node child;
9 Node sibling;
11 public Node (int depth) : this (depth, null) {}
13 public Node (int depth, Node sibling) {
14 if (depth > 0)
15 this.child = new Node (depth - 1);
17 this.sibling = sibling;
20 public override String ToString () {
21 return String.Format ("Node[child={0},sibling={1}]", this.child, this.sibling);
25 /**
26 * Usage : width [depth [collections]]
27 * - width : trigger the overflow
28 * - depth : modify the cost difference of the overflow
29 * - collections : # of collections to perform
31 public static void Main (String[] args) {
32 int width = 125;
33 if (args.Length > 0)
34 width = Math.Max (width, Int32.Parse (args [0]));
36 // Windows x64 only has 1 MB of stack per thread which is less than other x86 64-bit OSes.
37 // Using 10000 for depth will cause a stack overflow on Windows x64. 5000 will fit.
38 int platform = (int) Environment.OSVersion.Platform;
39 bool isWin64 = !(platform == 4 || platform == 128) && Environment.Is64BitProcess;
40 int depth = isWin64 ? 5000 : 10000;
41 if (args.Length > 1)
42 depth = Math.Max (depth, Int32.Parse (args [1]));
44 int collections = 100;
45 if (args.Length > 2)
46 collections = Math.Max (collections, Int32.Parse (args [2]));
48 Node sibling = null;
50 for (int i = 0; i < width; i++) {
51 sibling = new Node(depth, sibling);
52 if (i > 0 && i % 10 == 0)
53 Console.Write ("+");
56 for (int i = 0; i < collections; i++) {
57 GC.Collect();
58 if (i > 0 && i % 10 == 0)
59 Console.Write (".");
61 Console.WriteLine ();