Esempio n. 1
0
        public void RegexpBuildingPerformanceTest3()
        {
            Assert.Timeout(() =>
            {
                StringDistribution dist = StringFormatOp_RequireEveryPlaceholder_NoArgumentNames.FormatAverageConditional(
                    StringDistribution.String("aaaaaaaaaaa"),
                    new[] { StringDistribution.PointMass("a"), StringDistribution.PointMass("aa") });

                Console.WriteLine(dist.ToString());

                ProfileAction(() => RegexpTreeBuilder.BuildRegexp(dist.GetWorkspaceOrPoint()), 1000);
            }, 20000);
        }
Esempio n. 2
0
 /// <summary>
 /// Converts a given automaton to a regular expression corresponding to the support of the function.
 /// </summary>
 /// <typeparam name="TSequence">The type of sequences <paramref name="automaton"/> is defined on.</typeparam>
 /// <typeparam name="TElement">The type of sequence elements of <paramref name="automaton"/>.</typeparam>
 /// <typeparam name="TElementDistribution">The type of distributions over sequence elements of <paramref name="automaton"/>.</typeparam>
 /// <typeparam name="TSequenceManipulator">The type providing ways to manipulate instances of <typeparamref name="TSequence"/>.</typeparam>
 /// <typeparam name="TAutomaton">The concrete type of <paramref name="automaton"/>.</typeparam>
 /// <param name="automaton">The automaton to convert to a string.</param>
 /// <returns>The string representation of <paramref name="automaton"/>.</returns>
 public string ConvertToString<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>(
     Automaton<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton> automaton)
     where TSequence : class, IEnumerable<TElement>
     where TElementDistribution : IImmutableDistribution<TElement, TElementDistribution>, CanGetLogAverageOf<TElementDistribution>, CanComputeProduct<TElementDistribution>, CanCreatePartialUniform<TElementDistribution>, SummableExactly<TElementDistribution>, new()
     where TSequenceManipulator : ISequenceManipulator<TSequence, TElement>, new()
     where TAutomaton : Automaton<TSequence, TElement, TElementDistribution, TSequenceManipulator, TAutomaton>, new()
 {
     var regex = RegexpTreeBuilder.BuildRegexp(automaton);
     var builder = new StringBuilder();
     bool noTruncation = regex.AppendToString(builder,this.FormattingSettings);
     if (!noTruncation) builder.Append(" ... long regex truncated");
     return builder.ToString();
 }
Esempio n. 3
0
        public void RegexpBuildingPerformanceTest1()
        {
            Assert.Timeout(() =>
            {
                StringDistribution dist =
                    StringDistribution.OneOf(
                        StringDistribution.Lower() + StringDistribution.Upper() + StringDistribution.Optional(StringDistribution.Upper(2)),
                        StringDistribution.Digits(3) + StringDistribution.String("XXX") + StringDistribution.Letters(3, 5));

                Console.WriteLine(dist.ToString());

                ProfileAction(() => RegexpTreeBuilder.BuildRegexp(dist.GetWorkspaceOrPoint()), 6000);
            }, 10000);
        }
Esempio n. 4
0
        public void RegexpBuildingPerformanceTest2()
        {
            Assert.Timeout(() =>
            {
                StringDistribution dist = StringDistribution.OneOf(StringDistribution.Lower(), StringDistribution.Upper());
                for (int i = 0; i < 3; ++i)
                {
                    dist = StringDistribution.OneOf(dist, dist);
                }

                Console.WriteLine(dist.ToString());

                ProfileAction(() => RegexpTreeBuilder.BuildRegexp(dist.GetWorkspaceOrPoint()), 6000);
            }, 20000);
        }