dotnet / dotnet/wpf

WriteableBitmap performance increase.

Open
#5,246 9 comments 0 reactions 0 assignees View on GitHub
needs more information Question
Dominant language
C#
Stars
7.7k
Forks
1.3k
Avg merge
1d 11h
Merged PRs (30d)
61

Description

WriteableBitmap is fast (in Release and Debug modes) but it seems to be even faster in XAML Hot Reload Debug mode.
This performance in some cases doubles the Release performance.

My proposal is to identify what makes WriteableBitmap so fast in XAML Hot Reload Debug mode and use the same logic to Release.

The code for performance verification is the simplest possible.

_while (true)
{
Modelo2.ModelUpdate();
Application.Current.Dispatcher.Invoke(() => writeableBitmap.WritePixels(all, Modelo2.video_array, Modelo2.stride, 0, 0));
}_

_public static void ModelUpdate()
{
Buffer.BlockCopy(background, 0, video_array, 0, all_bytes);
... Model update logic removed to simplify. Left just a simple clean background per frame.
frames_counter++;
}_

To get the FPS rate there is a timer set to 1 second that collects the value of time (using System.Environment.TickCount64) and frames.

If necessary I can provide the full code.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.