code quality
Download
Report
Transcript code quality
[email protected]
[email protected]
MSIL bytecode
Machine code
C#
MSIL
MSIL MDIL
MDIL
native
code
Wordament on .NET Native:
Scenario
Improvement (%)
Cold Startup
39.32%
Warm Startup
31.21%
Memory Usage
12.68%
Enable
.NET
Native for
your
project
Debug and
test your
app with
.NET
Native
- Compile C# source code
- Generate & compile marshalling
and serialization code
- Merge all app & library code
- “Reduce” app to throw away unneeded
types, code, metadata, etc.
<Directives xmlns="http://schemas.microsoft.com/netfx/2013/01/metadata">
<Application>
<Assembly Name="*Application*" Dynamic="Required All" />
<!-- Add your application specific runtime directives here. -->
</Application>
</Directives>
The type specifies the class, namespace or assembly affected
The degree tells the compiler what behavior is needed
Reflection behaviors, Serialization behaviors, Interop behaviors
The policy notes the scope to apply that behavior inside the type
Accessibility: All, Public, Private, Internal
Required: Including this keyword means “Include these types in the final binary”
- C++ optimizer compiles MSIL to
MDIL, Machine Dependent
Intermediate Format. App is mostly
machine code but cannot execute.
- “Bind” MDIL app code into machine
code. App distributed as a stub,
app.exe, and app code in a dll. MRT
Runtime is distributed in the app
package, making the app package
self-sufficient.
for (long j = 0; j < numBodies; j++)
{
Float_4 r;
// From Nbody sample
r.x = A[j].pos.x - B.pos.x;
r.y = A[j].pos.y - B.pos.y;
r.z = A[j].pos.z - B.pos.z;
float distSqr = r.x * r.x + r.y * r.y + r.z * r.z;
distSqr += softeningSquared;
The C++
optimizer can
recognize this
code as
parallel and
generate
vector (SIMD)
instructions
float invDist = 1.0f / (float)Math1.Sqrt(distSqr);
float invDistCube = invDist * invDist * invDist;
float s = fParticleMass * invDistCube;
acc.x += r.x * s;
acc.y += r.y * s;
acc.z += r.z * s;
}
http://aka.ms/dotnetnative
http://blogs.msdn.com/b/dotnet
http://aka.ms/dotnetnative
[email protected]
.NET Native Forum
[email protected]
Blog
E-mail
dotnet
@dotnet
MSDN Forums
UserVoice