# Performance Difference Between Content.Load and Texture.FromStream xna

Is there any performance difference between Texture2Ds loaded using the content pipeline and Texture2Ds loaded using Texture2D.FromStream()?

Not a significant one, though this depends a lot on what you're trying to achieve. Keep in mind that Texture2D.FromStream() returns a default format of SurfaceFormat.Color /w non-premultiplied alpha data, whereas with the pipeline you have full control over what you want to do with the texture.

The distinguishing feature between the two is flexibility as opposed to performance. With that said, you really shouldn't decide between the two based on whatever miniscule difference in loading there maybe.

If you really need to know what that difference might be, you can just measure it yourself with a stopwatch.

Last time I was looking at benchmarks for this (quite some time ago), Texture2D.FromStream was actually faster than Content.Load<Texture2D>.

The overwhelmingly slowest part of the process, it turns out, is transferring data from disk.

When using Texture2D.FromStream, you can load a PNG or JPEG file. These file formats use image-specific data compression, resulting in very small files.

Whereas Content.Load<Texture2D> loads an XNB file which is the raw image data, with some general-purpose compression (in release builds), which results in a much larger file.

Even though decoding PNG or JPEG files is far more processor intensive, it ends up being faster, because your game doesn't spend as long waiting on the disk.

BUT: First of all, don't trust my results. Measure it yourself. It may be different on your hardware, or with your specific images. (IIRC, the first time I heard about this was for Windows Phone.)

And, this is an optimisation. Prefer to do the simple thing (Content.Load<Texture2D>) until and unless you have a compelling reason to do something else.