aspnet vnext でHello World

https://github.com/aspnet/Home にやり方がかいてあるので、その通りにやれば特にはまるところはなくきちんと動いてくれた。


c:\oss\aspnet>git clone https://github.com/aspnet/Home.git
c:\oss\aspnet>cd Home
c:\oss\aspnet\Home>kvmsetup.cmd
c:\oss\aspnet\Home>kvm install 0.1-alpha-build-0446 -p
c:\oss\aspnet\Home>kvm upgrade
c:\oss\aspnet\Home>kvm alias

Alias Name
----- ----
default KRE-svr50-x86.0.1-alpha-build-0481

ConsoleAppをビルド


c:\oss\aspnet\Home>cd samples\ConsoleApp
c:\oss\aspnet\Home\samples\ConsoleApp>dir /B
Program.cs
project.json
c:\oss\aspnet\Home\samples\ConsoleApp>type Program.cs
using System;

public class Program
{
public static void Main()
{
Console.WriteLine("Hello World");
}
}
c:\oss\aspnet\Home\samples\ConsoleApp>type project.json
{
"dependencies": {
"System.Console": "4.0.0.0"
},
"configurations": {
"net45": {},
"k10": {}
}
}
c:\oss\aspnet\Home\samples\ConsoleApp>kpm restore
c:\oss\aspnet\Home\samples\ConsoleApp>dir /B ..\..\packages
System.Console.4.0.0.0
System.IO.4.0.0.0
System.Runtime.4.0.20.0
System.Text.Encoding.4.0.10.0
System.Threading.Tasks.4.0.0.0
c:\oss\aspnet\Home\samples\ConsoleApp>k run
Hello World
c:\oss\aspnet\Home\samples\ConsoleApp>dir /B
Program.cs
project.json
c:\oss\aspnet\Home\samples\ConsoleApp>timeit k.cmd run
Hello World

Version Number: Windows NT 6.2 (Build 9200)
Exit Time: 3:47 pm, Sunday, June 1 2014
Elapsed Time: 0:00:08.627
Process Time: 0:00:00.078
System Calls: 103159
Context Switches: 31389
Page Faults: 36450
Bytes Read: 724277
Bytes Written: 1996379
Bytes Other: 120388

c:\oss\aspnet\Home\samples\ConsoleApp>SET KRE_TRACE=1
c:\oss\aspnet\Home\samples\ConsoleApp>k run
Loaded Module: klr.net45.dll
Found DLL Export: CallApplicationMain
klr.exe Information: 0 : RootHost.Load name=Microsoft.Framework.ApplicationHost
klr.exe Information: 0 : RootHost Assembly.LoadFile(Microsoft.Framework.ApplicationHost.dll)
klr.exe Information: 0 : RootHost.Load name=Microsoft.Framework.Runtime
klr.exe Information: 0 : RootHost Assembly.LoadFile(Microsoft.Framework.Runtime.dll)
klr.exe Information: 0 : RootHost.Load name=Newtonsoft.Json
klr.exe Information: 0 : RootHost Assembly.LoadFile(Newtonsoft.Json.dll)
klr.exe Information: 0 : Project root is c:\oss\aspnet\Home\samples\ConsoleApp
klr.exe Information: 0 : Walking dependency graph for 'ConsoleApp .NETFramework,Version=v4.5.1'.
klr.exe Information: 0 : [ProjectReferenceDependencyProvider]: ConsoleApp 1.0.0
klr.exe Information: 0 : [NuGetDependencyResolver]: System.Console 4.0.0.0
klr.exe Information: 0 : RootHost.Load name=Microsoft.Framework.Runtime.resources
klr.exe Information: 0 : Loading Microsoft.Framework.Runtime.resources for '.NETFramework,Version=v4.5.1'.
klr.exe Information: 0 : RootHost.Load name=Microsoft.Framework.Runtime.Roslyn
klr.exe Information: 0 : RootHost Assembly.LoadFile(Microsoft.Framework.Runtime.Roslyn.dll)
klr.exe Information: 0 : RootHost.Load name=Microsoft.CodeAnalysis
klr.exe Information: 0 : RootHost Assembly.LoadFile(Microsoft.CodeAnalysis.dll)
klr.exe Information: 0 : RootHost.Load name=System.Collections.Immutable
klr.exe Information: 0 : RootHost Assembly.LoadFile(System.Collections.Immutable.dll)
klr.exe Information: 0 : RootHost.Load name=System.Reflection.Metadata
klr.exe Information: 0 : RootHost Assembly.LoadFile(System.Reflection.Metadata.dll)
klr.exe Information: 0 : RootHost.Load name=Microsoft.CodeAnalysis.CSharp
klr.exe Information: 0 : RootHost Assembly.LoadFile(Microsoft.CodeAnalysis.CSharp.dll)
klr.exe Information: 0 : RootHost.Load name=Microsoft.Framework.Runtime.resources
klr.exe Information: 0 : Loading Microsoft.Framework.Runtime.resources for '.NETFramework,Version=v4.5.1'.
klr.exe Information: 0 : RootHost.Load name=Microsoft.Framework.Runtime.resources
klr.exe Information: 0 : Loading Microsoft.Framework.Runtime.resources for '.NETFramework,Version=v4.5.1'.
klr.exe Information: 0 : RootHost.Load name=Microsoft.Framework.Runtime.resources
klr.exe Information: 0 : Loading Microsoft.Framework.Runtime.resources for '.NETFramework,Version=v4.5.1'.
klr.exe Information: 0 : [ReferenceAssemblyDependencyResolver]: mscorlib 4.0.0.0, System 4.0.0.0, System.Core 4.0.0.0, Microsoft.CSharp 4.0.0.0
klr.exe Information: 0 : Resolved dependencies for ConsoleApp in 534ms
klr.exe Information: 0 : Loading entry point from ConsoleApp
klr.exe Information: 0 : RootHost.Load name=ConsoleApp
klr.exe Information: 0 : Loading ConsoleApp for '.NETFramework,Version=v4.5.1'.
klr.exe Information: 0 : [RoslynCompiler]: Found project 'ConsoleApp' framework=.NETFramework,Version=v4.5
klr.exe Information: 0 : [RoslynCompiler]: Loading dependencies for 'ConsoleApp'
klr.exe Information: 0 : [RoslynCompiler]: Completed loading dependencies for 'ConsoleApp' in 17ms
klr.exe Information: 0 : [RoslynCompiler]: Compiling 'ConsoleApp'
klr.exe Information: 0 : [RoslynCompiler]: Exported References 4
klr.exe Information: 0 : [RoslynAssemblyLoader]: Emitting assembly for ConsoleApp
klr.exe Information: 0 : [RoslynAssemblyLoader]: Emitted ConsoleApp in 4547ms
klr.exe Information: 0 : [LazyRoslynAssemblyLoader]: Finished loading ConsoleApp in 6884ms
klr.exe Information: 0 : Load took 7432ms
Hello World

kpm は npm のdotnet版みたいな感じだが nuget は健在だ。
会社のパソコンだと1秒以内で実行がおわるのでCPU性能に依存しているようだ。

visual C# ははやり早い。


c:\oss\aspnet\Home\samples\ConsoleApp>timeit csc.exe Program.cs
Microsoft (R) Visual C# Compiler version 12.0.30501.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.


Version Number: Windows NT 6.2 (Build 9200)
Exit Time: 3:53 pm, Sunday, June 1 2014
Elapsed Time: 0:00:00.558
Process Time: 0:00:00.453
System Calls: 19638
Context Switches: 2780
Page Faults: 7390
Bytes Read: 79255
Bytes Written: 69232
Bytes Other: 45451

c:\oss\aspnet\Home\samples\ConsoleApp>timeit Program.exe
Hello World

Version Number: Windows NT 6.2 (Build 9200)
Exit Time: 3:53 pm, Sunday, June 1 2014
Elapsed Time: 0:00:00.070
Process Time: 0:00:00.078
System Calls: 6569
Context Switches: 484
Page Faults: 4692
Bytes Read: 48117
Bytes Written: 55
Bytes Other: 19995

monoもそんなに遅くない。


c:\oss\aspnet\Home\samples\ConsoleApp>timeit mcs.bat Program.cs

Version Number: Windows NT 6.2 (Build 9200)
Exit Time: 3:54 pm, Sunday, June 1 2014
Elapsed Time: 0:00:01.915
Process Time: 0:00:00.031
System Calls: 20138
Context Switches: 6622
Page Faults: 11302
Bytes Read: 3388369
Bytes Written: 62366
Bytes Other: 37410

c:\oss\aspnet\Home\samples\ConsoleApp>timeit Program
Hello World

Version Number: Windows NT 6.2 (Build 9200)
Exit Time: 3:55 pm, Sunday, June 1 2014
Elapsed Time: 0:00:00.065
Process Time: 0:00:00.062
System Calls: 8621
Context Switches: 625
Page Faults: 4642
Bytes Read: 42125
Bytes Written: 445
Bytes Other: 17087

roslynの releases/build-preview ブランチでビルドしたrcscでやってみたが、一番おそいな。。。


c:\oss\aspnet\Home\samples\ConsoleApp>timeit rcsc.exe Program.cs
Microsoft (R) Visual C# Compiler version 0.6.0.0
Copyright (C) Microsoft Corporation. All rights reserved.


Version Number: Windows NT 6.2 (Build 9200)
Exit Time: 3:56 pm, Sunday, June 1 2014
Elapsed Time: 0:00:17.027
Process Time: 0:00:16.343
System Calls: 192017
Context Switches: 84470
Page Faults: 80516
Bytes Read: 24627016
Bytes Written: 248767
Bytes Other: 144112

c:\oss\aspnet\Home\samples\ConsoleApp>timeit Program
Hello World

Version Number: Windows NT 6.2 (Build 9200)
Exit Time: 3:57 pm, Sunday, June 1 2014
Elapsed Time: 0:00:00.061
Process Time: 0:00:00.062
System Calls: 5437
Context Switches: 416
Page Faults: 4469
Bytes Read: 41693
Bytes Written: 13
Bytes Other: 16493