fd9f72f5-7f1d-4257-a242-6a832de27581
true
smscentrevc.mgmwireless.com
true
true
master
true
<RuntimeDirectory>\Microsoft.VisualBasic.dll
<RuntimeDirectory>\System.Core.dll
<RuntimeDirectory>\System.dll
<RuntimeDirectory>\System.Numerics.dll
Microsoft.VisualBasic
System
static void Main() {
// JIT
TestUnrestricted(1,5);
TestUnrestricted("abc",5);
TestUnrestricted(1,5);
TestNullable(1, 5);
Console.WriteLine();
const int LOOP = 100000000;
Console.WriteLine(TestUnrestricted(1, LOOP));
Console.WriteLine(TestUnrestricted("abc", LOOP));
Console.WriteLine(TestUnrestricted(1, LOOP));
Console.WriteLine(TestNullable(1, LOOP));
Console.WriteLine();
Console.WriteLine(TestUnrestricted(0, LOOP));
Console.WriteLine(TestUnrestricted(null, LOOP));
Console.WriteLine(TestUnrestricted(null, LOOP));
Console.WriteLine(TestNullable(null, LOOP));
Console.WriteLine();
Console.WriteLine(TestUnrestricted(1, LOOP));
Console.WriteLine(TestUnrestricted("abc", LOOP));
Console.WriteLine(TestUnrestricted(1, LOOP));
Console.WriteLine(TestNullable(1, LOOP));
}
static long TestUnrestricted(T x, int loop) {
Stopwatch watch = Stopwatch.StartNew();
int count = 0;
for (int i = 0; i < loop; i++) {
if (x != null) count++;
}
watch.Stop();
Console.Write(count.ToString()+" ");
return watch.ElapsedMilliseconds;
}
static long TestNullable(T? x, int loop) where T : struct {
Stopwatch watch = Stopwatch.StartNew();
int count = 0;
for (int i = 0; i < loop; i++) {
if (x != null) count++;
}
watch.Stop();
Console.Write(count.ToString()+" ");
return watch.ElapsedMilliseconds;
}
#if(false)
// Output without the Console.Write(count.ToString()+" "):
27
27
6451
27
27
27
2428
26
27
26
6348
26
// and with:
5 5 5 5
100000000 193
100000000 187
100000000 6320
100000000 160
100000000 198
0 53
0 2448
0 53
100000000 193
100000000 180
100000000 6370
100000000 162
#endif