Showing posts with label performance. Show all posts
Showing posts with label performance. Show all posts

Fast = $$$ How do you make sure to have a fast application?

Speed = $$$
Many articles on the web, books and statistics tell us that “faster = better” and even more important: faster = more revenue.

For Google an increase in page load time from 0.4 second to 0.9 seconds decreased traffic and ad revenues by 20%.
For Amazon every 100 ms increase in load times decreased sales with 1%.

 

Also Google uses site speed in their web search ranking. So make sure to optimize your website for speed as per my other blog post.

Is Web Performance Optimization (WPO) something for you?

Avoid type casts - Use the "as" operator and check for null

Note: I don't care about measuring performance on these 2 operations because we don't use them in a tight loop.
For me its all about readability and robustness of my code.

Look at these code samples doing some type casts

        public List GetJobRulesFromPhysicalDB(DataTable renewedRules)
        {
            if (renewedRules.Rows.Count > 0 && CurrentJob.JobRules.Count > 0)
            {
                foreach (DataRow row in renewedRules.Rows)
                {
                    foreach (JobRule item in CurrentJob.JobRules)
                    {
                        if ((Guid)row["RuleID"] == item.RuleId)
                        {
                            item.UpdateRule(CurrentJob.RuleRepository.GetNewRuleByRuleId(item.RuleId));
                            break;
                        }
                    }
                }
            }

            return CurrentJob.JobRules;
        }
Figure: 1 code sample with untyped datatables

 

  
        private void AMControlMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            var auc = (AMUserControl)sender; 
            var aucSessionId = auc.myUserControl.Tag;
            // snip snip snip
   
        }
Figure: Event handler in Silverlight

I see this VERY often, so I had to blog about it.

Performance interview with LoadStorm

The company LoadStorm from Colorado U.S. did an interview with me about web performance and web testing.

I completely forgot to mention that here… so here is the link Peter Gfader
http://loadstorm.com/2010/performance-testing-interview-peter-gfader 

LoadStorm provides load testing from the cloud. Never saw such a nice and easy way (and UI) to hit your web servers VERY hard.
Only downside so far: No Silverlight runner … yet…

 

Additionally a couple of links to check the inner workings of your system...

Silverlight – The UI thread belongs to the browser!

To myself: Remember the following

Silverlight is “normally” hosted in the browser.
So, the single UI Thread should belong to the browser.

You can either learn that from different blogs, presentations or you learn it the hard way, like myself.

---------

.NET4 is too good to be true

Lately I played around the Parallel extensions in .NET 4 and I was almost impressed that it was better than expected :-)
--> In the initial example we did use Thread.Sleep inside the loops, so our speed up gain for going parallel was more than 4x …  :-)

Pre-requisites

  • I run this on VS2010 in a VPC with single CPU and around 1.5GB of RAM
  • There is no Disk IO or network IO involved in the benchmark
  • We have a long running process called DoCalc were we tested different algorithms from the port of the SciMark 2.0 Benchmark to C#
    The original benchmark was in Java and can be found at http://math.nist.gov/scimark2
  • I used the code from the “measureSOR” method, because
    • It takes the same time on each run (stable between consecutive runs)
    • It is the fastest one of all the calculation examples
  • The “measureSOR” method is a port of the SciMark2a Java Benchmark to C# by Chris Re (cmr28@cornell.edu ) and Werner Vogels (vogels@cs.cornell.edu )
    Thanks for that!

Code

See the following example (I removed all Debug output and Stopwatch code)

for (int i = 0; i < 5; i++)
            {
                DoCalc();
            }

And the same code with the Parallel extensions

Parallel.For(0, 5, i =>
            {
                DoCalc();
            });

The DoCalc is just a wrapper around measureSOR, because of easy replacing and testing

private static void DoCalc()
        {
            var res = PerformCalculationMeasureSOR();
        }

        private static double PerformCalculationMeasureSOR()
        {
            SciMark2.Random R = new SciMark2.Random(SciMark2.Constants.RANDOM_SEED);
            var res = SciMark2.kernel.measureSOR(SciMark2.Constants.SOR_SIZE, SciMark2.Constants.RESOLUTION_DEFAULT, R);
            return res;
        }

When we run these 2 methods we get

Output

Output from running in a for loop
Calculation process started at 26/08/2009 12:45:28 PM
Starting process 0
Run: 0   Result: 404.89
Completed process 0 took 5.4336615 seconds

Starting process 1
Run: 1   Result: 404.89
Completed process 1 took 4.7462174 seconds

Starting process 2
Run: 2   Result: 407.99
Completed process 2 took 4.7405446 seconds

Starting process 3
Run: 3   Result: 402.85
Completed process 3 took 4.7832635 seconds

Starting process 4
Run: 4   Result: 408.33
Completed process 4 took 4.7051044 seconds

Calculation finished at 26/08/2009 12:45:52 PM and took 24.418825
Hit <Enter>

Output from running parallel

Calculation process started at 26/08/2009 12:43:07 PM
Non-parallelized for loop
Starting process 0
Starting process 1
Starting process 2
Starting process 3
Starting process 4
Run: 2   Result: 68.17
Completed process 2 took 5.9277232 seconds

Run: 1   Result: 90.60
Completed process 1 took 9.0088243 seconds   // take longer because overlapping

Run: 0   Result: 90.45
Completed process 0 took 9.0282256 seconds   // take longer because overlapping

Run: 3   Result: 84.78
Completed process 3 took 5.2585445 seconds

Run: 4   Result: 192.39
Completed process 4 took 6.3435232 seconds

Calculation finished at 26/08/2009 12:43:20 PM and took 13.2818383
Hit <Enter>

 

Interesting notes here

  • In the NON parallel loop, each method call takes ~same amount of time
  • In the parallelized loop those methods that overlap, take longer (9 secs)
  • The parallel run in not 4x faster than the iterative run! (as it was with Thread.Sleep :-)
  • We almost halved the execution time as expected
    BUT sometimes the execution time is faster than half the time (around 10 seconds) image
     
  • Additionally if we run the parallel for loop 10 times we just need another 17 seconds...
    For an explanation we could have a deeper look at the algorithm behind SOR
    Jacobi Successive Over-relaxation (SOR) http://math.nist.gov/scimark2/about.html

clip_image002
Figure: Running the parallel for  10times takes only ~ 17 seconds

 

With the help of Paul we were able to figure out what is going on here…

Findings

Our findings running in the VPC image:

  • If we run the "normal" for loop, the CPU doesn't go crazy (only around 88%-98% of usage)
  • If we run the parallel loop , the CPU usage is much higher (~100%)

Our findings running on bare metal (real dual core CPU)

clip_image001
Figure 1.  Linear vs Parallel CPU utilization for loops

Conclusion

#1 CPU usage (=performance) is slightly scheduler dependent

I am not a OS expert but I guess the above means: “Windows sees more threads, and gives them more time on the CPU”

#2 Using the Parallel extensions is VERY EASY! Looking forward to the final release!

Infragistics controls compared ....

Infragistics Controls comparisonTranslation of the german post: Infragistics Controls Vergleich


In this post I show the results of a study made in our department about performance and handling in development with devexpress, Infragistics and Janus Controls

Infragistics controls
DevExpress Controls
Janus Controls


Information about:
- the company, number emloyees, clients, partner, references, presence in the market
- controls for which technology, .net2.0 .net3.0, support?
- sourcecode, quality
- performance of the single components
- usage of the controls in development, maintainment
- periodic regular updates? help? Support forum? Support mail, phone?
- what kind of controls? Prices?
- opinions from devleap members http://www.devleap.it/


Infragistics

Employees
Infragistics currently employs more than 100 industry professionals
Clients
IBM, Johnson & Johnson, Pfizer, Dell, United Airlines, Charles Schwab, AIG, Fidelity Group, Merrill Lynch
Partners
Microsoft, Sun, Ajilon Inc., Oracle, IBM, Borland
References (reference applications)
Tracker; Expense
Controls available for
Winforms; ASP.NET; COM; AJAX; Usability Testing,
Source Code?
YES
Source Code Quality
Very good, clean class diagram and composition
Usage of components
good; with many easy designers
Updates
regularly (4months); good
Help ms-help://
very good, with examples
Support Mail
Good fast reaction time
Controls
Grid
- Filter Row
- Extended functionality
UI Controls
-Explorerbar
-MDI Tabs
-Toolbar
-PanelManagement
Schedule Control: YES
Timeline Control
No; its in the Feature Request DB
Mail Question: Released when?
Productmanager Infragistics: "No, I can't provide that sort of information."
Prices
~1000€ for Winforms, Asp.net, com components with 1 year Priority Support and source code

opinions from Devleap
Translated by me… don’t blame me
Silvano: I know better Infragistics than the others and they seem very serious
Original ITALIAN: Io conosco In + Infragistics e mi sembrano molto seri. Altrimenti ho visto anche ComponentOne che non mi sembrano male, erano gratis dentro il VB.NET ResKit.
Brunetti: I know Infragistics, they are famous too for the web. The controls are a bit heavy and the assistance is not very good.
Original ITALIAN: Io conosco Infrangistics, sono famosi, anche per il web oltre che per windows.
In generale tutti questi prodotti sono un po' pesantoni e non offrono un'assistenza eccezionale.
Paolo: I vote for Infragistics, but only for Winforms, in Webforms they are horrible for a lot of Viewstate overhead…
Original ITALIAN: Io voto x Infragistics, ma solo per la parte Windows Forms.
La parte WebForm fa cacare con un sacco di Viewstate …
Marco: I vote for Infragistics too, but you should try ComponentOne, some of them seem very good. Infragistics is more a complete package (Winforms)
Original ITALIAN: Anche io voto Infragistics, ma digli di provare anche ComponentOne, per alcuni specifici componenti è meglio, ma come suite complessiva (per Windows Forms) Infragistics è più completo di tutti.



Performance of the grid control

Infragistics
testapplication:
Fetch data and paint the grid:
between 32 and 36 seconds (first time)

Sorting:
Bad average 10 seconds, the worst of all grids
No difference between sorting on numbers or text

Grouping:
between 28 and 30 seconds
Bad better than janus grid, but definitely worser than the XTRA Grid

Remove grouping:
circa 1 second, very fast

Filtering:
between 2,5 and 4,5 seconds, depending of the filter criteria
Bad Overall the slowest filter




devExpress
fetch data and paint the grid:
between 32 and 36 seconds (first time)
same performance as Infragistics

Sorting:
between 1,5 and 3 seconds, depending if I sort on numbers or text
Good definitely the fastest grid

Grouping:
between 2,5 and 4 seconds,
Good very fast on grouping

Remove grouping:

Good very fast, about 1 second

Filtering:
ActiveFilter, which filters on every keystroke.

Good Hard to compare to the others, cause it filters on every keypress, but this function seems very fast (between 2 and ~5 seconds), 5 seconds cause we input more letters




Janus Controls
fetch data and paint the grid:
between 36 and 39 seconds (first time)
Bad slowest buildup

sorting:
between 3 and 7,5 seconds , depending if we sort on numbers or text

grouping:
between 39 and 50 seconds,
Bad definitely the slowest grouping function of the 3 grids

remove grouping:
Bad slow, average 5-7 seconds

filtering:

Good fast filtering between 2 and 3,5 seconds




Comparison done with the actual versions from the software producers on 29 August 2005

Latest Posts

Popular Posts