Also, pay attention to the kind of loop you're using. Watch the difference:
public static void Main()
{
byte bresult = 0;
int iresult = 0;
Debug.Print(Utility.GetMachineTime().Ticks.ToString());
for (int i = 0; i < 20000; i++) { bresult += 1; }
Debug.Print(Utility.GetMachineTime().Ticks.ToString());
for (int i = 0; i < 20000; i++) { /* nothing */ }
Debug.Print(Utility.GetMachineTime().Ticks.ToString());
for (int i = 0; i < 20000; i++) { iresult += 1; }
Debug.Print(Utility.GetMachineTime().Ticks.ToString());
for (int i = 0; i < 20000; i++) { ++iresult; }
Debug.Print(Utility.GetMachineTime().Ticks.ToString());
}
Runned it a couple of times, output:
1436254933
1448545280 (difference: 12290347)
1456158720 (difference: 7613440)
1466142720 (difference: 9984000)
1476114133 (difference: 9971413)
2131536426
2144333013 (difference: 12796587)
2151945600 (difference: 7612587)
2161930026 (difference: 9984426)
2171901226 (difference: 9971200)
2337301760
2349823573 (difference: 12521813)
2357433813 (difference: 7610240)
2367418666 (difference: 9984853)
2377390080 (difference: 9971414)
The numbers are quite consistent.
This shows that incrementing with a byte consumes much more cycles then with an int. Could be because the range of a byte is exceeded many times. or because a byte is 8 bit and the system is 32-bit like the integer. I'm not sure what the difference exactly is. There is also a difference in performance beteen Value +=1 and ++Value.