public void ProduceLogs(int count, int buffSize)
        {
            var bufferOptions = new DataflowBlockOptions() { BoundedCapacity = buffSize };
            var writerOptions = new ExecutionDataflowBlockOptions() { BoundedCapacity = 10, MaxDegreeOfParallelism = 1, MaxMessagesPerTask = 10, SingleProducerConstrained = true };

            LogGenerator g = new LogGenerator();

            var file = new StreamWriter("basic.async.buff.log", false);

            BufferBlock<string> buffer = new BufferBlock<string>(bufferOptions);
            ActionBlock<string> writer = new ActionBlock<string>(s => file.WriteLine(s), writerOptions);

            buffer.LinkTo(writer, new DataflowLinkOptions() { PropagateCompletion = true });

            for (int i = 0; i < count; i++)
            {
                g.Next();

                var line = string.Format(g.FormatStr, g.Param1, g.Param2, g.Param3, g.Param4, g.Param5, g.Param6);
                writer.SendAsync(line).Wait();
            }

            buffer.Complete();

            Completed = writer.Completion.ContinueWith(t => file.Close());
        }
        public void ProduceLogs(int count, int buffSize)
        {
            LogGenerator g = new LogGenerator();

            using (var file = new FileStream("binary.proto.log", FileMode.Create))
            {

                for (int i = 0; i < count; i++)
                {
                    var entry = g.NextObject();
                    ProtoBuf.Serializer.Serialize(file, entry);
                }
            }
        }
        public void ProduceLogs(int count, int buffSize)
        {
            LogGenerator g = new LogGenerator();

            using (var file = new StreamWriter("basic.log", false))
            {
                for (int i = 0; i < count; i++)
                {
                    g.Next();

                    var line = string.Format(g.FormatStr, g.Param1, g.Param2, g.Param3, g.Param4, g.Param5, g.Param6);
                    file.WriteLine(line);
                }
            }
        }
        public void ProduceLogs(int count, int buffSize)
        {
            LogGenerator g = new LogGenerator();

            using (var file = new StreamWriter("binary.json.log", false))
            {
                using (JsonTextWriter writer = new JsonTextWriter(file))
                {
                    JsonSerializer serializer = new JsonSerializer();

                    for (int i = 0; i < count; i++)
                    {
                        g.Next();

                        var entry = new BinaryLogEntry();
                        entry.FormatStringCode = g.FormatStrCode;
                        entry.Parameters = new object[] { g.Param1, g.Param2, g.Param3, g.Param4, g.Param5, g.Param6 };

                        serializer.Serialize(writer, entry);
                    }
                }
            }
        }
        public void ProduceLogs(int count, int buffSize)
        {
            LogGenerator g = new LogGenerator();
            var queue = new BlockingCollection<ILogEntry>(buffSize);
            Completed = Task.Factory.StartNew(() => Write(queue, count));

            for (int i = 0; i < count; i++)
                queue.Add(g.NextObject());
        }
        public void ProduceLogs(int count, int buffSize)
        {
            LogGenerator g = new LogGenerator();
            BlockingCollection<string> queue = new BlockingCollection<string>(buffSize);
            Completed = Task.Factory.StartNew(() => Write(queue, count));

            for (int i = 0; i < count; i++)
            {
                g.Next();

                var line = string.Format(g.FormatStr, g.Param1, g.Param2, g.Param3, g.Param4, g.Param5, g.Param6);
                queue.Add(line);
            }
        }
        public void ProduceLogs(int count, int buffSize)
        {
            LogGenerator g = new LogGenerator();
            BlockingCollection<LogEntry> queue = new BlockingCollection<LogEntry>(buffSize);
            Completed = Task.Factory.StartNew(() => Write(queue, count));

            for (int i = 0; i < count; i++)
            {
                g.Next();

                var entry = new LogEntry() { format = g.FormatStr, parameters = new object[] { g.Param1, g.Param2, g.Param3, g.Param4, g.Param5, g.Param6 } };
                queue.Add(entry);
            }
        }
        public void ProduceLogs(int count, int buffSize)
        {
            var bufferOptions = new DataflowBlockOptions() { BoundedCapacity = buffSize, MaxMessagesPerTask = 10 };
            var writerOptions = new ExecutionDataflowBlockOptions() { BoundedCapacity = 10, MaxDegreeOfParallelism = 1, MaxMessagesPerTask = 10 };
            var serializerOptions = new ExecutionDataflowBlockOptions() { BoundedCapacity = 80, MaxDegreeOfParallelism = 8, SingleProducerConstrained = true, MaxMessagesPerTask = 10 };

            LogGenerator g = new LogGenerator();

            var file = new StreamWriter("basic.async.srlz.buff.log", false);

            BufferBlock<LogEntry> buffer = new BufferBlock<LogEntry>(bufferOptions);

            TransformBlock<LogEntry, string> serializer = new TransformBlock<LogEntry, string>(
                e => string.Format(e.format, e.parameters),
                serializerOptions);

            ActionBlock<string> writer = new ActionBlock<string>(s => file.WriteLine(s), writerOptions);

            buffer.LinkTo(serializer, new DataflowLinkOptions() { PropagateCompletion = true });
            serializer.LinkTo(writer, new DataflowLinkOptions() { PropagateCompletion = true });

            for (int i = 0; i < count; i++)
            {
                g.Next();

                var entry = new LogEntry() { format = g.FormatStr, parameters = new object[] { g.Param1, g.Param2, g.Param3, g.Param4, g.Param5, g.Param6 } };
                buffer.SendAsync(entry).Wait();
            }

            buffer.Complete();

            Completed = writer.Completion.ContinueWith(t => file.Close());
        }