As of changeset 9c5d78cac927, you can now specify the /optimize option to instruct Dafny.exe to produce an optimized build of your program.
- Dafny will pass the /optimize flag to the C# compiler, which is similar to producing a release build.
You will need a copy of Microsoft's new immutable collections assembly (System.Collections.Immutable.dll) to be in the same directory that you invoke Dafny.exe from.
1. Download a copy of the NuGet.exe command line utility from nuget.org (you can also install it using a Powershell package manager such as scoop).
2. Use the NuGet.exe utility to install the Microsoft.Bcl.Immutable into a temporary directory. e.g:
3. Find the System.Collections.Immutable.dll assembly. In the example provided above, this assembly could be found in C:\tmp\Microsoft.Bcl.Immutable.1.0.34\lib\portable-net45+win8+wp8+wpa81\. Copy this assembly to the directory where you intend to invoke Dafny.exe from.
4. You are now ready to pass the /optimize flag to Dafny.exe from the directory where you deposited the System.Collections.Immutable.dll assembly.
-
What does this mean?
- Dafny will enable an optimized version of the prelude that is included in the C# code it generates by passing /define:DAFNY_USE_SYSTEM_COLLECTIONS_IMMUTABLE to the C# compiler.- Dafny will pass the /optimize flag to the C# compiler, which is similar to producing a release build.
Fulfilling /optimize Prerequisites
The optimized version of the prelude uses Microsoft's new immutable collections, which perform much better than Dafny's default collections. This requires a copy of Microsoft's new immutable collections to be in the current directory when invoking Dafny.exe.You will need a copy of Microsoft's new immutable collections assembly (System.Collections.Immutable.dll) to be in the same directory that you invoke Dafny.exe from.
1. Download a copy of the NuGet.exe command line utility from nuget.org (you can also install it using a Powershell package manager such as scoop).
2. Use the NuGet.exe utility to install the Microsoft.Bcl.Immutable into a temporary directory. e.g:
PS C:\tmp> nuget install Microsoft.Bcl.Immutable Installing 'Microsoft.Bcl.Immutable 1.0.34'. Successfully installed 'Microsoft.Bcl.Immutable 1.0.34'. PS C:\tmp>
3. Find the System.Collections.Immutable.dll assembly. In the example provided above, this assembly could be found in C:\tmp\Microsoft.Bcl.Immutable.1.0.34\lib\portable-net45+win8+wp8+wpa81\. Copy this assembly to the directory where you intend to invoke Dafny.exe from.
4. You are now ready to pass the /optimize flag to Dafny.exe from the directory where you deposited the System.Collections.Immutable.dll assembly.
-