Exemplo n.º 1
0
        public static string JunkTSV(int days)
        {
            int count = recordsPerDay * days;

            var start = DateTime.Today.AddDays(-days).AddHours(DateTime.Now.Hour).AddMinutes((DateTime.Now.Minute / 5) * 5);
            StringBuilder sb = new StringBuilder();
            sb.AppendLine("date	total	sessions	fallback	ratio");
            var random = new Random(12345);
            var ratio = .1m;
            for (var i = 0; i < count; i++)
            {
                var offset = start - peak;
                var periodInDay = (offset.Hour * 60 + offset.Minute) / 5;
                var r = Convert.ToDouble(periodInDay) * radiansPerPeriod;
                var cosR = (Math.Cos(r) + 1D) / 2D; // map it to [0,1]
                var numUsers = Convert.ToInt32((range * cosR) + minUsers);

                var record = new HopperCount
                {
                    Date = start,
                    TotalCount =  numUsers,
                    FallbackRatio = ratio + (Decimal) (random.NextDouble() / 10D) - .05M
                };

                sb.AppendLine(record.ToString());
                start = start.AddMinutes(recordPeriodMinutes);
            }
            return sb.ToString();
        }
Exemplo n.º 2
0
 private static HopperCount ExpectedFirstRecord()
 {
     var expected = new HopperCount
     {
         Date = DateTime.Parse("2012-12-05T17:00:00.0000000-08:00"),
         FallbackHoppers = 106,
         FallbackRatio = .057M,
         Sessions = 139562,
         TotalCount = 186273
     };
     return expected;
 }