示例#1
0
 public static bool IsMeme(string phrase)
 {
     // Runs and returns the control
     // Runs the experiment as well (but does not return it)
     return(Scientist.Science <bool>("recording-results-example", experiment => {
         experiment.Use(() => MemeBot2000.IsMeme(phrase)); // Control
         experiment.Try(() => MemeBot3000.IsMeme(phrase)); // Candidate
     }));
 }
        public static bool IsMeme(string phrase)
        {
            return(Scientist.Science <bool>("adding-context-example", experiment => {
                // If you add context here...
                experiment.AddContext("phrase", phrase);
                experiment.AddContext("when", DateTimeOffset.Now);

                experiment.Use(() => MemeBot2000.IsMeme(phrase)); // Control
                experiment.Try(() => MemeBot3000.IsMeme(phrase)); // Candidate
            }));
        }
        public static bool IsMeme(string phrase)
        {
            // Runs and returns the control
            // Runs the experiment as well (but does not return it)

            // Note! This doesn't actually output or record anything about the experiment.
            // To see how that's done, look at 02-RecordingResultsExample.cs.
            return(Scientist.Science <bool>("basic-example", experiment => {
                experiment.Use(() => MemeBot2000.IsMeme(phrase)); // Control
                experiment.Try(() => MemeBot3000.IsMeme(phrase)); // Candidate
            }));
        }
        public static bool IsMeme(string phrase)
        {
            return(Scientist.Science <bool>("sampling-example", experiment => {
                experiment.AddContext("phrase", phrase);
                experiment.AddContext("when", DateTimeOffset.Now);

                // Let's say we only want to run the experiment 50% of the time
                experiment.RunIf(() => rng.Next(10) < 5);

                experiment.Use(() => MemeBot2000.IsMeme(phrase)); // Control
                experiment.Try(() => MemeBot3000.IsMeme(phrase)); // Candidate
            }));
        }
示例#5
0
        public static bool IsMeme(string phrase)
        {
            return(Scientist.Science <bool>("conditional-example", experiment => {
                experiment.AddContext("phrase", phrase);
                experiment.AddContext("when", DateTimeOffset.Now);

                // Let's say we only want to run the experiment if people are excited.
                // This means the experiment will only run when the phrase ends with an bang (!)
                experiment.RunIf(() => !string.IsNullOrWhiteSpace(phrase) && phrase.EndsWith('!'));

                experiment.Use(() => MemeBot2000.IsMeme(phrase)); // Control
                experiment.Try(() => MemeBot3000.IsMeme(phrase)); // Candidate
            }));
        }
        public static bool IsMeme(string phrase)
        {
            return(Scientist.Science <bool>("random-order-example", experiment => {
                experiment.AddContext("phrase", phrase);
                experiment.AddContext("when", DateTimeOffset.Now);

                experiment.Use(() => {
                    // Let's print out when this ran so we can see if the control ran first.
                    Console.WriteLine($"{nameof(MemeBot2000)} kicking it at {DateTimeOffset.Now.Ticks}!");
                    return MemeBot2000.IsMeme(phrase);
                });// Control
                experiment.Try(() => {
                    // Let's print out when this ran so we can see if the candidate ran first.
                    Console.WriteLine($"{nameof(MemeBot3000)} kicking it at {DateTimeOffset.Now.Ticks}!");
                    return MemeBot3000.IsMeme(phrase);
                }); // Candidate
            }));
        }