Example #1
0
        public static void CreateBinaryData(string fileName, string mainSeed = "TasksChooser.RandomTest", int contOfColumns = 100, int contOfRows = 100000)
        {
            var rndForSeeds = new TaskRandom(mainSeed);
            var rnds        = new TaskRandom[contOfColumns];

            using (var stream = File.Create(fileName))
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    // 1st row = seeds
                    for (int col = 0; col < contOfColumns; col++)
                    {
                        double d    = rndForSeeds.NextDouble();
                        string seed = Convert.ToBase64String(BitConverter.GetBytes(d));
                        rnds[col] = new TaskRandom(seed);
                        writer.Write(d);
                    }

                    // numbers
                    int tenPercent = contOfRows / 10;
                    for (int row = 0; row < contOfRows; row++)
                    {
                        for (int col = 0; col < contOfColumns; col++)
                        {
                            writer.Write(rnds[col].NextDouble());
                        }
                        //if (row % tenPercent == 0)
                        //    Console.WriteLine("{0:N0}%", 100 * row / (double)contOfRows);
                    }
                }
            //Console.WriteLine("{0:N0}%", 100);
        }
Example #2
0
        public static void CreateTextData(string fileName, string seed = "TasksChooser.RandomTest", int count = 1000000)
        {
            var rnd = new TaskRandom(seed);

            using (var stream = File.Create(fileName))
                using (var writer = new StreamWriter(stream))
                {
                    // numbers
                    int tenPercent = count / 10;
                    for (int row = 0; row < count; row++)
                    {
                        writer.WriteLine(rnd.NextDouble()); //.ToString(CultureInfo.InvariantCulture));
                        if (row % tenPercent == 0)
                        {
                            Console.WriteLine("{0:N0}%", 100 * row / (double)count);
                        }
                    }
                }
            Console.WriteLine("{0:N0}%", 100);
        }