Roslyn Code Gems - Performance Goals

Friday, February 13, 2015

Ever since the .NET compiler platform became open source, I’ve been poking around the Roslyn source code. It’s not often you get to look at the internals of a product with a large code base, and not surprisingly there are some gems inside. I have a collection of the gems and each gem falls into one of three categories.

1. Ideas to borrow

2. Trivia

3. Bizarre and outstanding

Today’s gem falls into category two – trivia.

Have you ever wondered what makes for a “captive” audience? According to the PerformanceGoals class, this would be an operation using from one to ten seconds of time.

static PerformanceGoals()
{
    // An interaction class defines how much time is expected to reach a time point, the response 
    // time point being the most commonly used. The interaction classes correspond to human perception,
    // so, for example, all interactions in the Fast class are perceived as fast and roughly feel like 
    // they have the same performance. By defining these interaction classes, we can describe 
    // performance using adjectives that have a precise, consistent meaning.
    //
    // Name             Target (ms)     Upper Bound (ms)        UX / Feedback
    // Instant          <=50            100                     No noticeable delay
    // Fast             50-100          200                     Minimally noticeable delay
    // Typical          100-300         500                     Slower, but still no feedback necessary
    // Responsive       300-500         1,000                   Slower yet, potentially show Wait cursor
    // Captive          >500            10,000                  Long, show Progress Dialog w/Cancel
    // Extended         >500            >10,000                 Long enough for the user to switch to something else

    // Used for throughput scenarios like parser bytes per second.
    const string Throughput_100 = "Throughput_100";

    Goals = new string[(int)FunctionId.Count];
    Goals[(int)FunctionId.CSharp_SyntaxTree_FullParse] = Throughput_100;
    Goals[(int)FunctionId.VisualBasic_SyntaxTree_FullParse] = Throughput_100;
}

Unlike the code in this post, the next entry in this series will feature a gem with potentially useful code – an optimized bit counter.


Comments
gravatar Matt Warren Tuesday, February 17, 2015
Hey, great minds think alike, I had exactly the same idea. Although I only focussed on the performance side of things. If you interested in other performance lessons from Roslyn see http://mattwarren.org/2014/06/05/roslyn-code-base-performance-lessons-part-1/ and http://mattwarren.org/2014/06/10/roslyn-code-base-performance-lessons-part-2/
gravatar Scott Tuesday, February 17, 2015
@Matt - Sweet, I will be linking to those posts in this series. :)
gravatar Matt Warren Tuesday, February 17, 2015
Thanks, glad you like them. Shameless plug, but I also just did a Hansleminutes talking about this kind of thing, you might enjoy that as well. I actually talk about the exact performance goals that you blogged about, see http://www.hanselminutes.com/458/performance-as-a-feature-with-matt-warren
Comments are closed.

My Pluralsight Courses

K.Scott Allen OdeToCode by K. Scott Allen
What JavaScript Developers Should Know About ECMAScript 2015
The Podcast!