using System;
using System.Diagnostics;
struct Test
{
int i;
public Test(int i)
{
this.i = i;
}
public void Init(int i)
{
this.i = i;
}
}
class Program
{
static void Main(string[] args)
{
const int length = 0x1000000;
var tests = new Test[length];
for (var i = 0; i < length; i++)
tests[i] = new Test(i);
for (var i = 0; i < length; i++)
tests[i].Init(i);
for (var i = 0; i < length; i++)
tests[i] = new Test(i);
for (var i = 0; i < length; i++)
tests[i].Init(i);
var s = new Stopwatch();
s.Start();
for (var j = 0; j < 3; j++)
for (var i = 0; i < length; i++)
tests[i] = new Test(i);
s.Stop();
Console.WriteLine(".ctor(): {0}ms", s.ElapsedMilliseconds);
s.Start();
for (var j = 0; j < 3; j++)
for (var i = 0; i < length; i++)
tests[i].Init(i);
s.Stop();
Console.WriteLine("Init(): {0}ms", s.ElapsedMilliseconds);
}
}
dXNpbmcgU3lzdGVtOwp1c2luZyBTeXN0ZW0uRGlhZ25vc3RpY3M7CgpzdHJ1Y3QgVGVzdAp7CglpbnQgaTsKCXB1YmxpYyBUZXN0KGludCBpKQoJewoJCXRoaXMuaSA9IGk7Cgl9CglwdWJsaWMgdm9pZCBJbml0KGludCBpKQoJewoJCXRoaXMuaSA9IGk7Cgl9Cn0KCmNsYXNzIFByb2dyYW0KewoJc3RhdGljIHZvaWQgTWFpbihzdHJpbmdbXSBhcmdzKQoJewoJCWNvbnN0IGludCBsZW5ndGggPSAweDEwMDAwMDA7CgkJdmFyIHRlc3RzID0gbmV3IFRlc3RbbGVuZ3RoXTsKCgkJZm9yICh2YXIgaSA9IDA7IGkgPCBsZW5ndGg7IGkrKykKCQkJdGVzdHNbaV0gPSBuZXcgVGVzdChpKTsKCQlmb3IgKHZhciBpID0gMDsgaSA8IGxlbmd0aDsgaSsrKQoJCQl0ZXN0c1tpXS5Jbml0KGkpOwoJCWZvciAodmFyIGkgPSAwOyBpIDwgbGVuZ3RoOyBpKyspCgkJCXRlc3RzW2ldID0gbmV3IFRlc3QoaSk7CgkJZm9yICh2YXIgaSA9IDA7IG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