DEV Community

Cory Harkins
Cory Harkins

Posted on

I Did My Own Small Benchmark. C# - List of Int vs Array of Int

I consider myself an easy going guy. I like coffee, the simple things in life. Lists in my programming.

But after doing some reading and reading some debates online, I decided to run a small benchmark myself on Lists vs Arrays.

I did this with an extremely small set of data. I started the C# Stopwatch class and ran the clock over setting up the data structure, populating it, and then looping through those items in it.

Both sets of data held integers 1 through 10.

It took 00:00:00.0230056 seconds to process the list.
It took 00:00:00.0008005 seconds to process the array.

That is a ridiculously smaller amount of time to process the array.

CRAZY.

I wrote more on medium if you want to follow the article there.

Thanks!

My Medium Account

Top comments (2)

Collapse
 
djnitehawk profile image
Dĵ ΝιΓΞΗΛψΚ

for this kind of benchmarking it's always better to use benchmarkdotnet.org over stopwatch.

Collapse
 
charkinsdevelopment profile image
Cory Harkins

That's great to know! I had never heard of it!