protected override void DoHandleWork(WorkContext work) { var cnt = work.MatchedVars["cnt"].AsInt(10); var pretty = work.MatchedVars["pretty"].AsBool(true); if (cnt > 10000) { cnt = 10000; } if (cnt < 0) { cnt = 1; } var lst = new List <object>(); for (var i = 0; i < cnt; i++) { lst.Add(new { FirstName = NaturalTextGenerator.GenerateFirstName(), MiddleName = NaturalTextGenerator.GenerateFirstName(), LastName = NaturalTextGenerator.GenerateLastName(), Address = "{0}\n{1}".Args(NaturalTextGenerator.GenerateAddressLine(), NaturalTextGenerator.GenerateUSCityStateZip()), Email = NaturalTextGenerator.GenerateEMail() }); } work.Response.WriteJSON(lst, pretty ? NFX.Serialization.JSON.JSONWritingOptions.PrettyPrint : NFX.Serialization.JSON.JSONWritingOptions.Compact); }
public static HumanName Build() { return(new HumanName { FirstName = NaturalTextGenerator.GenerateFirstName(), MiddleName = ExternalRandomGenerator.Instance.NextRandomInteger > 500000000 ? NaturalTextGenerator.GenerateFirstName() : null, LastName = NaturalTextGenerator.GenerateLastName() }); }
private static string[] Generate(int arraySize) { var array = new string[arraySize]; for (var index = 0; index < array.Length; index++) { array[index] = NaturalTextGenerator.GenerateFirstName(); } return(array); }
public static TradingRec Build() { return(new TradingRec { Symbol = NaturalTextGenerator.GenerateFirstName(), Volume = ExternalRandomGenerator.Instance.NextScaledRandomInteger(-25000, 25000), Bet = ExternalRandomGenerator.Instance.NextScaledRandomInteger(-250000, 250000) * 10000L, Price = ExternalRandomGenerator.Instance.NextScaledRandomInteger(0, 1000000) * 10000L }); }
public void GenerateFirstNames() { for (var i = 0; i < 100; i++) { var txt = NaturalTextGenerator.GenerateFirstName(); Console.WriteLine(txt); Assert.IsTrue(txt.IsNotNullOrWhiteSpace()); Assert.IsTrue(txt.Length >= 3); Assert.IsTrue(txt.Length <= 20); } }
public static PER_PartyContactInformation Make() { return(new PER_PartyContactInformation { Contact_Function_Code = "RP", Name = NaturalTextGenerator.GenerateFirstName(), CommunicationNumber1 = CommunicationNumber.Make(), CommunicationNumber2 = CommunicationNumber.Make(), CommunicationNumber3 = CommunicationNumber.Make(), Contact_Inquiry_Reference = NaturalTextGenerator.GenerateWord() }); }
public void PerfFullInfo() { const int CNT = 1000000; var sw = Stopwatch.StartNew(); for (var i = 0; i < CNT; i++) { var name = NaturalTextGenerator.GenerateFirstName() + " " + NaturalTextGenerator.GenerateLastName(); var addr = NaturalTextGenerator.GenerateAddressLine(); var csz = NaturalTextGenerator.GenerateUSCityStateZip(); } var elapsed = sw.ElapsedMilliseconds; var ops = CNT / (elapsed / 1000d); Console.WriteLine("Genereated {0} full infos, in {1:n0} ms at {2:n0} ops/sec", CNT, elapsed, ops); Assert.IsTrue(ops > 180000);//180,000 ops/sec }
public static NM1_PartyName Make() { return(new NM1_PartyName { Entity_Identifier_Code = "EI", Entity_Type_Qualifier = "QQ", Name_Last_or_Organization_Name = NaturalTextGenerator.GenerateFullName(), Name_First = NaturalTextGenerator.GenerateFirstName(), Name_Middle = NaturalTextGenerator.GenerateFirstName(), Name_Prefix = "Mrs.", Name_Suffix = "Jr", Identification_Code_Qualifier = "CQ", Identification_Code = NaturalTextGenerator.GenerateWord(), Entity_Relationship_Code = NaturalTextGenerator.GenerateWord(), Entity_Identifier_Code2 = NaturalTextGenerator.GenerateWord(), Name_Last_or_Organization_Name2 = NaturalTextGenerator.GenerateLastName() }); }
public void PerfFullInfo_Parallel() { const int CNT = 3000000; var sw = Stopwatch.StartNew(); System.Threading.Tasks.Parallel.For(0, CNT, (i) => { var name = NaturalTextGenerator.GenerateFirstName() + " " + NaturalTextGenerator.GenerateLastName(); var addr = NaturalTextGenerator.GenerateAddressLine(); var csz = NaturalTextGenerator.GenerateUSCityStateZip(); }); var elapsed = sw.ElapsedMilliseconds; var ops = CNT / (elapsed / 1000d); Assert.IsTrue(ops > 750000);//750,000 ops/sec Console.WriteLine("Genereated {0} full infos, in {1:n0} ms at {2:n0} ops/sec", CNT, elapsed, ops); }
public void AnalyzeUniqueness(int CNT) { var fnames = new List <string>(); var lnames = new List <string>(); var flnames = new List <string>(); var cities = new List <string>(); for (var i = 0; i < CNT; i++) { var fn = NaturalTextGenerator.GenerateFirstName(); fnames.Add(fn); var ln = NaturalTextGenerator.GenerateLastName(); lnames.Add(ln); flnames.Add(fn + " " + ln); cities.Add(NaturalTextGenerator.GenerateCityName()); } Console.WriteLine("Generated {0:n0} times", CNT); Console.WriteLine("----------------------------"); var dfn = fnames.Distinct().Count(); var pfn = 100d * (dfn / (double)CNT); Console.WriteLine(" First names {0:n0} unique {1:n3}%", dfn, pfn); var dln = lnames.Distinct().Count(); var pln = 100d * (dln / (double)CNT); Console.WriteLine(" Last names {0:n0} unique {1:n3}%", dln, pln); var dfln = flnames.Distinct().Count(); var pfln = 100d * (dfln / (double)CNT); Console.WriteLine(" First+Last names {0:n0} unique {1:n3}%", dfln, pfln); Assert.IsTrue(pfln > 85d);//85% uniqueness var dct = cities.Distinct().Count(); var pct = 100d * (dct / (double)CNT); Console.WriteLine(" Cities {0:n0} unique {1:n3}%", dct, pct); Console.WriteLine(); }
public void GenerateFullInfo() { for (var i = 0; i < 100; i++) { var name = NaturalTextGenerator.GenerateFirstName() + " " + NaturalTextGenerator.GenerateLastName(); var addr = NaturalTextGenerator.GenerateAddressLine(); var csz = NaturalTextGenerator.GenerateUSCityStateZip(); Console.WriteLine(name); Console.WriteLine(addr); Console.WriteLine(csz); Console.WriteLine("-------------------------------------------"); Assert.IsTrue(name.IsNotNullOrWhiteSpace()); Assert.IsTrue(addr.IsNotNullOrWhiteSpace()); Assert.IsTrue(csz.IsNotNullOrWhiteSpace()); Assert.IsTrue(name.Length >= 3); Assert.IsTrue(name.Length <= 100); Assert.IsTrue(addr.Length >= 3); Assert.IsTrue(addr.Length <= 100); Assert.IsTrue(csz.Length >= 3); Assert.IsTrue(csz.Length <= 100); } }
public static TypicalPersonData MakeRandom() { var rnd = ExternalRandomGenerator.Instance.NextRandomInteger; var data = new TypicalPersonData { FirstName = NaturalTextGenerator.GenerateFirstName(), MiddleName = ExternalRandomGenerator.Instance.NextRandomInteger > 500000000 ? NaturalTextGenerator.GenerateFirstName() : null, LastName = NaturalTextGenerator.GenerateLastName(), DOB = DateTime.Now.AddYears(ExternalRandomGenerator.Instance.NextScaledRandomInteger(-90, -1)), Salary = ExternalRandomGenerator.Instance.NextScaledRandomInteger(30, 250) * 1000m, YearsOfService = 25, CreditScore = 0.7562, RegisteredToVote = (DateTime.UtcNow.Ticks & 1) == 0, MaritalStatus = MaritalStatus.HatesAll, Address1 = NaturalTextGenerator.GenerateAddressLine(), Address2 = NaturalTextGenerator.GenerateAddressLine(), AddressCity = NaturalTextGenerator.GenerateCityName(), AddressState = "CA", AddressZip = "91606", HomePhone = (DateTime.UtcNow.Ticks & 1) == 0 ? "(555) 123-4567" : null, EMail = NaturalTextGenerator.GenerateEMail() }; if (0 != (rnd & (1 << 32))) { data.Notes = NaturalTextGenerator.Generate(45); } if (0 != (rnd & (1 << 31))) { data.SkypeID = NaturalTextGenerator.GenerateEMail(); } if (0 != (rnd & (1 << 30))) { data.YahooID = NaturalTextGenerator.GenerateEMail(); } if (0 != (rnd & (1 << 29))) { data.IsSmoker = 0 != (rnd & (1 << 17)); } if (0 != (rnd & (1 << 28))) { data.IsLoving = 0 != (rnd & (1 << 16)); } if (0 != (rnd & (1 << 27))) { data.IsLoved = 0 != (rnd & (1 << 15)); } if (0 != (rnd & (1 << 26))) { data.IsDangerous = 0 != (rnd & (1 << 14)); } if (0 != (rnd & (1 << 25))) { data.IsEducated = 0 != (rnd & (1 << 13)); } if (0 != (rnd & (1 << 24))) { data.LastSmokingDate = DateTime.Now.AddYears(-10); } if (0 != (rnd & (1 << 23))) { data.DesiredSalary = rnd / 1000m; } if (0 != (rnd & (1 << 22))) { data.ProbabilityOfSpaceFlight = rnd / (double)int.MaxValue; } if (0 != (rnd & (1 << 21))) { data.CurrentFriendCount = rnd % 123; data.DesiredFriendCount = rnd % 121000; } return(data); }
// public object SomeObject; public static TypicalPersonData MakeRandom(bool extraData = false) { var rnd = ExternalRandomGenerator.Instance.NextRandomInteger; var data = new TypicalPersonData { FirstName = NaturalTextGenerator.GenerateFirstName(), MiddleName = ExternalRandomGenerator.Instance.NextRandomInteger > 500000000 ? NaturalTextGenerator.GenerateFirstName() : null, LastName = NaturalTextGenerator.GenerateLastName(), DOB = DateTime.Now.AddYears(ExternalRandomGenerator.Instance.NextScaledRandomInteger(-90, -1)), Salary = ExternalRandomGenerator.Instance.NextScaledRandomInteger(30, 250) * 1000m, YearsOfService = 25, CreditScore = 0.7562, RegisteredToVote = (DateTime.UtcNow.Ticks & 1) == 0, MaritalStatus = MaritalStatus.HatesAll, Address1 = NaturalTextGenerator.GenerateAddressLine(), Address2 = NaturalTextGenerator.GenerateAddressLine(), AddressCity = NaturalTextGenerator.GenerateCityName(), AddressState = "CA", AddressZip = "91606", HomePhone = (DateTime.UtcNow.Ticks & 1) == 0 ? "(555) 123-4567" : null, EMail = NaturalTextGenerator.GenerateEMail() }; //if (extraData) // data.SomeObject = new Dictionary<object, object> // { // { "1aaaaa", TypicalPersonData.MakeRandom(false)}, { 2212, -234123}, {13000,100}, { Tuple.Create(2, false,true), "yes"}, {"4aaa",'a'}, // { "a2aaaa", TypicalPersonData.MakeRandom(false)}, { 132, TypicalPersonData.MakeRandom(false)}, {130400,100}, { Tuple.Create(3, false,true), "yes"}, {"a234aa",'a'}, // { "aa4aaa", TypicalPersonData.MakeRandom(false)}, { 412, -123}, {2100d,100L}, { Tuple.Create(4, false,TypicalPersonData.MakeRandom(false)), "yes"}, {"a5aa",'a'}, // { "aa3aaa", TypicalPersonData.MakeRandom(false)}, { 212, 0}, {1222200m,100}, { Tuple.Create(5, false,true), "yes"}, {"a43aa1",'a'}, // { "a5aaaa", TypicalPersonData.MakeRandom(false)}, { 512, new int[]{1,2,-3,4,5,-6,-1,-2,-3,-4,5,6,1,2,3,4,5,6,1,2,3,4,5,6,1,2,3,4,5,60}}, // {102200,100}, { Tuple.Create(-213232d, false,false), "yes"}, {"222222222222aaa",'a'}, // }; if (0 != (rnd & (1 << 32))) { data.Notes = NaturalTextGenerator.Generate(45); } if (0 != (rnd & (1 << 31))) { data.SkypeID = NaturalTextGenerator.GenerateEMail(); } if (0 != (rnd & (1 << 30))) { data.YahooID = NaturalTextGenerator.GenerateEMail(); } if (0 != (rnd & (1 << 29))) { data.IsSmoker = 0 != (rnd & (1 << 17)); } if (0 != (rnd & (1 << 28))) { data.IsLoving = 0 != (rnd & (1 << 16)); } if (0 != (rnd & (1 << 27))) { data.IsLoved = 0 != (rnd & (1 << 15)); } if (0 != (rnd & (1 << 26))) { data.IsDangerous = 0 != (rnd & (1 << 14)); } if (0 != (rnd & (1 << 25))) { data.IsEducated = 0 != (rnd & (1 << 13)); } if (0 != (rnd & (1 << 24))) { data.LastSmokingDate = DateTime.Now.AddYears(-10); } if (0 != (rnd & (1 << 23))) { data.DesiredSalary = rnd / 1000m; } if (0 != (rnd & (1 << 22))) { data.ProbabilityOfSpaceFlight = rnd / (double)int.MaxValue; } if (0 != (rnd & (1 << 21))) { data.CurrentFriendCount = rnd % 123; data.DesiredFriendCount = rnd % 121000; } return(data); }