20 static PinList
MakeList (int length
)
23 for (int i
= 0; i
< length
; ++i
)
28 static void AssignReferences (PinList l
, Pinned
[] objs
)
34 l
.reference
= objs
[i
++ % n
];
39 static Pinned
Work (PinList list
, Pinned
[] objs
, int i
)
43 for (int j
= 0; j
< 10; ++j
)
46 AssignReferences (list
, objs
);
52 Pinned obj
= new Pinned ();
54 Pinned dummy
= Work (list
, objs
, i
+ 1);
55 return obj
!= dummy
? obj
: dummy
; // to keep obj alive
59 static void Benchmark (PinList list
, int n
)
61 Pinned
[] objs
= new Pinned
[n
];
65 public static void Main ()
67 PinList list
= MakeList (1 << 24);
68 Console
.WriteLine ("long list constructed");
71 Benchmark (list
, 100);