using System;
using System.Collections.Generic;
namespace Glass.PerformanceTests
{
///
/// What the command line narrows a full run to.
///
public sealed class RunOptions
{
public const string OptionPrefix = "--";
public const string SteadyOnlyOption = OptionPrefix + "steady-only";
public const string Usage =
"Usage: Glass.PerformanceTests [--x86] [--x64] [--steady-only] [text in the scenario names to run]";
public string ScenarioFilter = "";
///
/// Labels of the bitnesses to run; empty runs every one that's built.
///
public readonly HashSet Bitnesses = new HashSet();
public bool SteadyOnly;
public bool Wants(string bitness)
{
return Bitnesses.Count == 0 || Bitnesses.Contains(bitness);
}
///
/// Null when the command line is malformed.
///
public static RunOptions Parse(string[] args)
{
var returnMe = new RunOptions();
bool sawFilter = false;
foreach (string arg in args)
{
if (arg == SteadyOnlyOption)
{
returnMe.SteadyOnly = true;
}
else if (arg == OptionPrefix + ProcessVariant.X86 || arg == OptionPrefix + ProcessVariant.X64)
{
returnMe.Bitnesses.Add(arg.Substring(OptionPrefix.Length));
}
else if (arg.StartsWith(OptionPrefix, StringComparison.Ordinal) || sawFilter)
{
return null;
}
else
{
returnMe.ScenarioFilter = arg;
sawFilter = true;
}
}
return returnMe;
}
}
}