20 static int list_size
= 0;
22 static PinList
MakeList (int length
)
25 for (int i
= 0; i
< length
; ++i
)
30 static void AssignReferences (PinList l
, Pinned
[] objs
)
36 l
.reference
= objs
[i
++ % n
];
41 static Pinned
Work (PinList list
, Pinned
[] objs
, int i
)
45 for (int j
= 0; j
< 10; ++j
)
47 MakeList (list_size
>> 5);
48 AssignReferences (list
, objs
);
54 Pinned obj
= new Pinned ();
56 Pinned dummy
= Work (list
, objs
, i
+ 1);
57 return obj
!= dummy
? obj
: dummy
; // to keep obj alive
61 static void Benchmark (PinList list
, int n
)
63 Pinned
[] objs
= new Pinned
[n
];
67 public static void Main ()
70 TestTimeout timeout
= TestTimeout
.Start(TimeSpan
.FromSeconds(TestTimeout
.IsStressTest
? 60 : 5));
72 for (int it1
= 1; it1
<= 10; it1
++, list_size
<<= 1) {
73 PinList list
= MakeList (list_size
);
74 Console
.WriteLine ("long list constructed {0}", it1
);
75 for (int it2
= 0; it2
< 5; it2
++) {
76 Benchmark (list
, 10 * it1
);
79 if (!timeout
.HaveTimeLeft
)