public void Run(Action <List <ThriftMention> > cacheFullCallback) { List <ThriftMention> cache = new List <ThriftMention>(); Stopwatch sw = new Stopwatch(); //Console.WriteLine("Starting generation of " + this.TotalItems.ToString() + " items..."); sw.Start(); for (int i = 0; i < TotalItems; i++) { //var date = BeforeTodaySource.Next(); var date = new DateTime(2011, 9, day + 1, hour, NextRand(interval * 10, (interval * 10 + 10)), NextRand(0, 60)); string guidValue; if (Guids != null && NextRand(0, 101) < GuidReusePercentage) { guidValue = Guids[NextRand(0, Guids.Length)].ToString(); } else { guidValue = GetRandomMd5Hash(); } var newItem = new ThriftMention { Sentiment = NextRand(-100, 101), Influence = NextRand(0, 101), Name = ShortTextSource.Next(), Description = null, //TextSource.Next(), OccurredOnTicks = date.Ticks, Guid = guidValue }; newItem.CreatedOnTicks = new DateTime(newItem.OccurredOnTicks).AddDays(rand.Next(0, 5)).AddHours(NextRand(0, 10)).AddMinutes(NextRand(0, 60)).Ticks; int numTags = NextRand(0, 10); newItem.Tags = new List <int>(); for (int j = 0; j < numTags; ++j) { var targetTag = Tags[NextRand(0, Tags.Length)]; newItem.Tags.Add(targetTag.Id); } cache.Add(newItem); if ((i + 1) % (CacheSize) == 0 && i > 0) { cacheFullCallback.Invoke(cache); cache.Clear(); } } sw.Stop(); //Console.WriteLine("Finished generation in: " + sw.Elapsed.ToString()); }
public void Run(Action<List<ThriftMention>> cacheFullCallback) { List<ThriftMention> cache = new List<ThriftMention>(); Stopwatch sw = new Stopwatch(); //Console.WriteLine("Starting generation of " + this.TotalItems.ToString() + " items..."); sw.Start(); for (int i = 0; i < TotalItems; i++) { //var date = BeforeTodaySource.Next(); var date = new DateTime(2011, 9, day + 1, hour, NextRand(interval*10, (interval*10+10)),NextRand(0,60)); string guidValue; if (Guids != null && NextRand(0, 101) < GuidReusePercentage) guidValue = Guids[NextRand(0, Guids.Length)].ToString(); else guidValue = GetRandomMd5Hash(); var newItem = new ThriftMention { Sentiment = NextRand(-100, 101), Influence = NextRand(0, 101), Name = ShortTextSource.Next(), Description = null, //TextSource.Next(), OccurredOnTicks = date.Ticks, Guid = guidValue }; newItem.CreatedOnTicks = new DateTime(newItem.OccurredOnTicks).AddDays(rand.Next(0, 5)).AddHours(NextRand(0, 10)).AddMinutes(NextRand(0, 60)).Ticks; int numTags = NextRand(0, 10); newItem.Tags = new List<int>(); for (int j = 0; j < numTags; ++j) { var targetTag = Tags[NextRand(0, Tags.Length)]; newItem.Tags.Add(targetTag.Id); } cache.Add(newItem); if ((i + 1) % (CacheSize) == 0 && i > 0) { cacheFullCallback.Invoke(cache); cache.Clear(); } } sw.Stop(); //Console.WriteLine("Finished generation in: " + sw.Elapsed.ToString()); }