-
Notifications
You must be signed in to change notification settings - Fork 261
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Introduce measure-complexity command #3061
Merged
keyboardDrummer
merged 20 commits into
dafny-lang:master
from
keyboardDrummer:stabilityCommand
Dec 16, 2022
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
4438bfb
Add check-stability command
keyboardDrummer 0cf53df
Run formatter
keyboardDrummer c2b268e
Update tests
keyboardDrummer 8b0ef0a
Fix test
keyboardDrummer 0d408f4
Fix text and default value
keyboardDrummer b65f8f4
Fix cast and tests
keyboardDrummer 718b344
Update Source/DafnyDriver/Commands/StabilityCommand.cs
keyboardDrummer 93cdea2
Merge remote-tracking branch 'origin/master' into stabilityCommand
keyboardDrummer bbfdd48
Textual changes
keyboardDrummer 2f57e17
Merge remote-tracking branch 'origin/master' into stabilityCommand
keyboardDrummer c31cbe5
Rename command name
keyboardDrummer f9d453d
Use all the options in tests
keyboardDrummer 35f5827
Rename and set Compile=false
keyboardDrummer 1519621
Fix tests
keyboardDrummer d367f90
Merge branch 'master' into stabilityCommand
keyboardDrummer d10bba5
Rename to measure-complexity
keyboardDrummer d28bd48
Update description
keyboardDrummer d8f055e
Update description
keyboardDrummer f15adfb
Merge branch 'master' into stabilityCommand
robin-aws 9fa9121
Merge branch 'master' into stabilityCommand
keyboardDrummer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System.Collections.Generic; | ||
using System.CommandLine; | ||
using System.CommandLine.Invocation; | ||
using System.Linq; | ||
|
||
namespace Microsoft.Dafny; | ||
|
||
public class MeasureComplexityCommand : ICommandSpec { | ||
public IEnumerable<Option> Options => new Option[] { | ||
Iterations, | ||
RandomSeed, | ||
Format, | ||
IsolateAssertions, | ||
}.Concat(ICommandSpec.VerificationOptions). | ||
Concat(ICommandSpec.CommonOptions); | ||
|
||
static MeasureComplexityCommand() { | ||
DafnyOptions.RegisterLegacyBinding(Iterations, (o, v) => o.RandomSeedIterations = (int)v); | ||
DafnyOptions.RegisterLegacyBinding(RandomSeed, (o, v) => o.RandomSeed = (int)v); | ||
DafnyOptions.RegisterLegacyBinding(IsolateAssertions, (o, v) => o.VcsSplitOnEveryAssert = v); | ||
DafnyOptions.RegisterLegacyBinding(Format, (o, v) => o.VerificationLoggerConfigs = v); | ||
} | ||
|
||
private static readonly Option<uint> RandomSeed = new("--random-seed", () => 0U, | ||
$"Turn on randomization of the input that Dafny passes to the SMT solver and turn on randomization in the SMT solver itself. Certain Dafny proofs are complex in the sense that changes to the proof that preserve its meaning may cause its verification result to change. This option simulates meaning-preserving changes to the proofs without requiring the user to actually make those changes. The proof changes are renaming variables and reordering declarations in the SMT input passed to the solver, and setting solver options that have similar effects."); | ||
|
||
private static readonly Option<uint> Iterations = new("--iterations", () => 10U, | ||
$"Attempt to verify each proof n times with n random seeds, each seed derived from the previous one. {RandomSeed.Name} can be used to specify the first seed, which will otherwise be 0.") { | ||
ArgumentHelpName = "n" | ||
}; | ||
|
||
private static readonly Option<bool> IsolateAssertions = new("--isolate-assertions", @"Verify each assertion in isolation."); | ||
|
||
private static readonly Option<List<string>> Format = new("--format", $@" | ||
Logs verification results using the given test result format. The currently supported formats are `trx`, `csv`, and `text`. These are: the XML-based format commonly used for test results for .NET languages, a custom CSV schema, and a textual format meant for human consumption. You can provide configuration using the same string format as when using the --logger option for dotnet test, such as: --format ""trx;LogFileName=<...>""); | ||
|
||
The `trx` and `csv` formats automatically choose an output file name by default, and print the name of this file to the console. The `text` format prints its output to the console by default, but can send output to a file given the `LogFileName` option. | ||
|
||
The `text` format also includes a more detailed breakdown of what assertions appear in each assertion batch. When combined with the {IsolateAssertions.Name} option, it will provide approximate time and resource use costs for each assertion, allowing identification of especially expensive assertions.".TrimStart()) { | ||
ArgumentHelpName = "configuration" | ||
}; | ||
|
||
public Command Create() { | ||
var result = new Command("measure-complexity", "(Experimental) Measure the complexity of verifying the program."); | ||
result.AddArgument(ICommandSpec.FilesArgument); | ||
return result; | ||
} | ||
|
||
public void PostProcess(DafnyOptions dafnyOptions, Options options, InvocationContext context) { | ||
dafnyOptions.Compile = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like a bit more detail here personally ("Verify each assertion in its own assertion batch. See (refman section) for details.") but not enough to block on.