Reputation: 6485
I am trying to measure how long it takes for different Silverlight charting libraries (e.g. Silverlight Control Toolkit, Visifire, Telerik) to load on screen.
My problem is that I can only measure the time until the control is loaded and drawing starts to take place on the screen, however rendering takes more time because of animation effects (e.g. points fading in).
Is there any chance I can set up some automated way of detecting when the rendering has ended? My problem is that I only found the Loaded event handler on a Silverlight Framework element to hook on to which only notifies of when rendering starts.
An example code I am currently using for Silverlight Control Toolkit is as follows:
public void Init()
{
Chart chart = new Chart(); // Init chart object
DataPointSeries series;
(...)// Init series, add lots of points, set data binding
Chart.Series.Add(series); // Add series to chart
chart.Loaded += new RoutedEventHandler(Chart_Loaded);
LayoutRoot.Children.Add(chart);
StartTimer(); // Start timer and wait for control to load
}
public void Chart_Loaded(object sender, RoutedEventArgs e)
{
StopTimer(); // Problem: rendering just started at this point, hasn't finished yet!
}
Upvotes: 4
Views: 1888
Reputation: 6485
I've found some workarounds for some chart libraries and for some others I did not. Here are the events I could hook up to to get a realistic measurement time:
Dundas Charts:
Chart chart;
Chart.ImageReady += new ImageDownloaded(Chart_ImageReady); // Stop timer at this event
Silverlight Toolkit:
Chart chart;
DataPointSeries series;
Chart.Series.Add(series);
Chart.Series[0].Loaded += new RoutedEventHandler(Chart_Loaded); // Stop timer at this event
Steema TeeChart:
TChart chart;
chart.AfterDraw += new PaintChartEventHandler(chart_AfterDraw); // Stop timer at this event
Telerik RAD Charts:
RadChart chart;
chart.DefaultView.ChartArea.Loaded += new RoutedEventHandler(Chart_Loaded); // Stop timer at this event
Visifire
Chart chart;
chart.AnimationEnabled = false; // Turn off animation
chart.Loaded += new RoutedEventHandler(Chart_Loaded); // Stop timer at this event
The only library I couldn't hook up to an event fired at the right time was for Infagristics Netadvantage.
Upvotes: 4
Reputation: 358
In case you are trying to compare the performance, I think including animation is not the best way to determine the rendering time of a control because different animations can take different amount of time to complete.
I would rather suggest that you disable animation if possible while testing. In Visifire you can do so by setting AnimationEnabled property of Chart to false. Am not much aware of others. And while performing such tests you can make the differences more apparent by using huge number of DataPoints (4K-5K).
Upvotes: 2