WinFX Trivia Quiz: What are the most used APIs in the BCL?


A guy on my team has been playing around with an API usage frequency tool… the idea is to gather data on the most used APIs in the framework.  What he does is scan the IL for all calls to methods and sum the number of calls for each API defined in the BCL.  


He recently ran this tool over a current build of Longhorn which contains a large managed code base.  Can you name any of the methods in the top 10?  Think about it a bit, it might be harder than you first think… I’ll post a hint tomorrow if folks are not in the right track.

Comments (15)

  1. Albert says:

    String.Compare

  2. Jesse Ezell says:

    10. Microsoft.PlatformSpecificApi.Use();

    9. Hardware.Ram.MaxOut();

    8. Microsoft.Office.Crash();

    7. System.Windows.BlueScreen.Display();

    6. W3C.Standards.Ignore(true);

    5. Secrets.UndocumentedClass.ReallyCoolMethod();

    4. Marketing.Xmlizer.Xmlize(Everything);

    3. System.Math.Random.CreateAcronym();

    2. ScobleVisibleAttribute.ctor(false);

    1. Drinks.KoolAid.Pour();

  3. Simon Smith says:

    String.Compare is good.

    XmlDocument.SelectSingleNode and .SelectNodes

  4. Scott says:

    Control.Invalidate ?

    Dispose ?

    Debug.WriteLine ?

    Stream.Read ?

  5. Eric Wilson says:

    – Anything in the String class (particularily String.Format).

    – Probably the ctor for Exception.

    – XPathNavigator.Select();

  6. Brad Abrams says:

    Good guesses so far… this is not really a hint, more of clarification. For the purposes of this question assume the BCL is only stuff in MSCorLib and System.dll — so no xml.

  7. Ken Cowan says:

    Are you counting how many calls are in the source or which get called the most at runtime?

    System.String functions. Do I need to guess which ones? .ctor and Compare would be my guess.

    System.StringBuilder.

    ArrayList and/or HashTable insert and enumerators.

    Demand on various permissions.

    ToString on various types

    IntPtr.op_Equal

    KC

  8. Josh says:

    Convert.ToXXX()

  9. System.Object::.ctor (maybe not called, but certainly used)

    System.IO.MemoryStream.ReadByte

    System.Text.StringBuilder::GetThreadSafeString

    (and perhaps other string functions like NullTerminate?)

  10. Eric says:

    Probably a lower level than considered, but how about:

    object.ctor()

    object.Equals()

    followed by the ctors for various integer types…

  11. I’d have to go with object.ToString and its overrides, but those will probably come up separate in the statistics. how about object.GetType()?

  12. Brad Abrams says:

    Good comments… A couple of folks suggest string.Compare()… The most frequent overload of it is only the 51st most called api, with 295 calls.

    51;System.String.Compare(System.String strA;System.String strB,Boolean ignoreCase;System.Globalization.CultureInfo culture);295

    Other folks have suggested items higher on the list as well.

    Here is your hint: Consider method calls that are not "hidden" by C# or VB syntax…

  13. Keith Hill says:

    String.Length

    String.op_Equality / String.Equals

    String.Empty

    ArgumentException.ctor

    ArgumentNullException.ctor