blob: 6b41eead52b8e9de527b39d3413fd140a9319af4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
//
using System;
public class PerfNotIf
{
/**@dll.import("kernel32.dll")*/
//private static native int GetTickCount();
int icount = 100000000;
bool m_i;
PerfNotIf()
{
m_i = true;
/* JVM
GetTickCount();
int t1 = GetTickCount();
notIf(m_i);
int t2 = GetTickCount();
System.out.println("Time for not & if:\t" + (t2-t1) + " ms");
*/
/* SMC */
int t1 = Environment.TickCount;
notIf(m_i);
int t2 = Environment.TickCount;
Console.WriteLine("Time for not & if:\t" + (t2 - t1) + " ms");
}
private bool notIf(bool i)
{
for (int k = 0; k < icount; k++)
if (i)
i = !i;
else
i = !i;
return i;
}
public static int Main(String[] args)
{
new PerfNotIf();
return 100;
}
}
|