T
The Last Danish Pastry
If I run this program:
=======================================
using System;
using System.Runtime.InteropServices;
namespace QPC
{
class Class1
{
[DllImport("Kernel32.dll")]
private static extern bool QueryPerformanceCounter(out long
lpPerformanceCount);
[STAThread]
static void Main(string[] args)
{
const int N = 120;
long[] a = new long[N];
for (int i = 0; i < N; ++i)
{
QueryPerformanceCounter(out a);
}
for (int i = 1; i < N; ++i)
{
Console.WriteLine(i.ToString()+": "+(a-a[i-1]).ToString());
}
Console.ReadLine();
} // Main
} // Class1
} // QPC
=======================================
I get this output:
=======================================
1: 37
2: 26
3: 26
4: 25
5: 25
6: 26
7: 25
8: 25
9: 25
10: 26
11: 448
12: 38
13: 25
14: 25
15: 24
16: 25
17: 24
18: 25
19: 25
20: 25
21: 25
22: 27
23: 25
24: 25
25: 25
26: 26
27: 25
28: 25
29: 25
30: 26
31: 25
32: 25
33: 25
34: 26
35: 25
36: 25
37: 25
38: 26
39: 25
40: 25
41: 25
42: 25
43: 24
44: 25
45: 24
46: 26
47: 25
48: 25
49: 25
50: 26
51: 25
52: 25
53: 25
54: 25
55: 25
56: 25
57: 25
58: 25
59: 25
60: 25
61: 24
62: 26
63: 24
64: 25
65: 24
66: 25
67: 25
68: 25
69: 24
70: 26
71: 25
72: 25
73: 25
74: 25
75: 25
76: 26
77: 25
78: 26
79: 24
80: 26
81: 26
82: 26
83: 25
84: 26
85: 25
86: 26
87: 25
88: 25
89: 25
90: 25
91: 24
92: 25
93: 24
94: 25
95: 25
96: 25
97: 24
98: 26
99: 24
100: 1564
101: 10
102: 6
103: 6
104: 5
105: 6
106: 7
107: 6
108: 6
109: 5
110: 6
111: 5
112: 6
113: 5
114: 7
115: 6
116: 5
117: 6
118: 6
119: 6
=======================================
Why, after 100 calls to QPC, does it suddenly speed up?
This behavior is consistent. I have run it on three computers running
different flavours of Windows.
I am using:
Microsoft Development Environment 2003 Version 7.1.3088
Microsoft .NET Framework 1.1 Version 1.1.4322
=======================================
using System;
using System.Runtime.InteropServices;
namespace QPC
{
class Class1
{
[DllImport("Kernel32.dll")]
private static extern bool QueryPerformanceCounter(out long
lpPerformanceCount);
[STAThread]
static void Main(string[] args)
{
const int N = 120;
long[] a = new long[N];
for (int i = 0; i < N; ++i)
{
QueryPerformanceCounter(out a);
}
for (int i = 1; i < N; ++i)
{
Console.WriteLine(i.ToString()+": "+(a-a[i-1]).ToString());
}
Console.ReadLine();
} // Main
} // Class1
} // QPC
=======================================
I get this output:
=======================================
1: 37
2: 26
3: 26
4: 25
5: 25
6: 26
7: 25
8: 25
9: 25
10: 26
11: 448
12: 38
13: 25
14: 25
15: 24
16: 25
17: 24
18: 25
19: 25
20: 25
21: 25
22: 27
23: 25
24: 25
25: 25
26: 26
27: 25
28: 25
29: 25
30: 26
31: 25
32: 25
33: 25
34: 26
35: 25
36: 25
37: 25
38: 26
39: 25
40: 25
41: 25
42: 25
43: 24
44: 25
45: 24
46: 26
47: 25
48: 25
49: 25
50: 26
51: 25
52: 25
53: 25
54: 25
55: 25
56: 25
57: 25
58: 25
59: 25
60: 25
61: 24
62: 26
63: 24
64: 25
65: 24
66: 25
67: 25
68: 25
69: 24
70: 26
71: 25
72: 25
73: 25
74: 25
75: 25
76: 26
77: 25
78: 26
79: 24
80: 26
81: 26
82: 26
83: 25
84: 26
85: 25
86: 26
87: 25
88: 25
89: 25
90: 25
91: 24
92: 25
93: 24
94: 25
95: 25
96: 25
97: 24
98: 26
99: 24
100: 1564
101: 10
102: 6
103: 6
104: 5
105: 6
106: 7
107: 6
108: 6
109: 5
110: 6
111: 5
112: 6
113: 5
114: 7
115: 6
116: 5
117: 6
118: 6
119: 6
=======================================
Why, after 100 calls to QPC, does it suddenly speed up?
This behavior is consistent. I have run it on three computers running
different flavours of Windows.
I am using:
Microsoft Development Environment 2003 Version 7.1.3088
Microsoft .NET Framework 1.1 Version 1.1.4322