If you are developing an application for the Windows 8 Store it is very important that you test it on an ARM device (Surface RT, Asus VivoTab RT, Dell XPS 10,etc.) before sending it into certification. You will probably have some bad surprises and not everything that was fast&fluid on your development machine will continue to be so on an ARM device (the list scroll performance reminds me of the first version of Windows Phone). So you will have to simplify the layouts, animations and in some cases even rewrite part of your code. Parallel Programming is your friend if you can use it (for Kids' Orchestra I had the big problem that generating 100ms of sound output took more then 100ms so after 2 days of trying to optimize the C# source code I realized that I only had to use the Parallel.For and everything started working).
Due to performance differences you might need to split the user experience/code on different architectures (like disabling some animations on ARM). If this is the case it becomes very important to know the processor architecture on which your application runs. One solution would be to create 3 different packages of your applications and use the conditional compilation to differentiate between what happens on each architecture. If you still want to use only one package (Any CPU) it is enough to have a method that returns the processor architecture.
The bad news is that WinRT framework doesn't have any method/property that returns the processor architecture (at least I don't know it). The good news is that you can still use GetNativeSystemInfo as it is an api supported for Windows Store apps (it is even supported for Windows Phone 8 apps):
The bad news is that WinRT framework doesn't have any method/property that returns the processor architecture (at least I don't know it). The good news is that you can still use GetNativeSystemInfo as it is an api supported for Windows Store apps (it is even supported for Windows Phone 8 apps):
For Windows Store apps you can use two approaches to call this api:
1. Use P/Invoke -this is the one I opted for;
2. Create a Windows Runtime Component in C++ that you can then call from managed code - this is the approach you will have to use if you need to call this function on Windows Phone 8.
What I did is to create a public class, which I called CPU, and has one public static property NativeInfo that returns an SystemInfo object:
public class SystemInfo
{
public ProcessorArchitecture ProcessorArchitecture;
public ushort ProcessorArchitectureId;
public ProcessorType ProcessorType;
public uint ProcessorTypeId;
public uint NumberOfProcessors;
public ushort ProcessorLevel;
public ushort ProcessorRevision;
public uint AllocationGranularity;
};
and a public method IsProcessorFeaturePresent (invoking also a supported Api for Windows Store applications) which returns if a certain ProcessorFeature feature is supported or not.
I have also created a small sample that will give you a list with your processor details. Here is the result I got on my Surface:
Hope you will find the class useful. Don't hesitate to contact me if you need further details.
SOURCE CODE:
CPU.cs and Sample Project
NAMASTE!
0 comments:
Post a Comment