Would these 2 different Sorting methods makes a difference in performance?

Hi I'm using vs2012.
My page is loading up slow.  I was wondering if there is a performance difference to these 2 Sort methods?  The sorted collection is then bind to a gridview control in my web page.

List<UserPrincipal> users = new List<UserPrincipal>();
users.OrderBy(x => x.SamAccountName).ToList();
and
users.Sort(delegate(UserPrincipal a, UserPrincipal b) { return string.Compare(a.SamAccountName, b.SamAccountName); });

Thank you.
lapuccaAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

käµfm³d 👽Commented:
My guess would be that the OrderBy call is a tad slower due to the overhead of LINQ/iterators. However, I doubt that you would notice the difference. Do you observe the same behavior under debug?
lapuccaAuthor Commented:
I set some break points my my code to see where the bottle neck is and nada was causing the delay except for VS took about 5 seconds to hit the first BP in the begining of Page_Load event.  Is that normal?  So the sorting loc didn't slow down the program at all.  I don't know why it's taking so long to load the page.
käµfm³d 👽Commented:
It does take some time--not much, mind you--for Visual Studio to attach to the running IIS process (locally) in order for you to be able to debug. There's not much (if anything) that you can do about that. The only other thing I can think of off the top of my head would be are you making a database query?
Amazon Web Services

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

lapuccaAuthor Commented:
Well, this web page only has a gridview control.  The data source of the grid is  List<UserPrincipal>.   I bind to an Active Directory Security Group, I then populate all the members in that group, currently there are 60 members.  Sort those users and add them to that collection to bind to the gridview control.  

I deploy to a vm web server that is 64bit with 8GB ram.  Looking at task manager, it only runs about 1.6 GB and spiking here and there with cpu but nothing out of place.  Don't know why it takes so long to load up this web page from the web server.
käµfm³d 👽Commented:
The AD bind could be the culprit. Have you tried timing that bit of code with something like StopWatch?
lapuccaAuthor Commented:
Nice tool!  Thanks.  
Should I start the StopWatch at the 1st loc of Page_Load event and then stop at the last loc of the same event to get a measure?  Or would recommend other starting/stopping event /loc for using this class?
käµfm³d 👽Commented:
I would wrap anything that you suspect is taking a long time to process. You can start a new SW using the StartNew method. Once you call Stop, you'll want to inspect one of the Elapsed*** methods, like ElapsedMilliseconds. You can dump that info out to the page (for debugging). This should help give you an idea as to where the hangup is.
lapuccaAuthor Commented:
I used the example code here, https://msdn.microsoft.com/en-us/library/system.diagnostics.stopwatch%28v=vs.110%29.aspx?f=255&MSPPError=-2147217396.  
I called Start method at the begining of the Page_Load then stop as the last loc of the Page_load event.  This is the time elapsed,             elapsedTime      "00:00:00.85"      string.

Less than one second to load the page.  That includes all the backend C# code to bind to ldap, sort and bind to gridview control. I think that's pretty good.  But now I wonder where is the bottle neck for slowing loading of my program when I run it from the web server.  

What I can do next to do deploy to the web server with code for Stopwatch but write the elapsed time to my debug log file on the C drive.  If that still come up less than a second then would it be reasonable to conclude that the bottleneck is with the Web Server?  (Can't be the network traffic because my local pc and the web server are both on the same network at work).
käµfm³d 👽Commented:
If that still come up less than a second then would it be reasonable to conclude that the bottleneck is with the Web Server?
Potentially.

You might also look into Performance Counters. I haven't used them myself, but my understanding is that they help diagnose issues such as these. There are many counters already built in to Windows and IIS, and you can even create your own custom counters.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lapuccaAuthor Commented:
Very helpful, thank you very much!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.