Beispiel #1
0
        private static void InternalParserByteSpanToBool(string text)
        {
            bool value;
            int  bytesConsumed;

            byte[] utf8ByteArray             = Encoding.UTF8.GetBytes(text);
            ReadOnlySpan <byte> utf8ByteSpan = new ReadOnlySpan <byte>(utf8ByteArray);
            EncodingData        fd           = EncodingData.InvariantUtf8;
            TextFormat          nf           = new TextFormat('N');

            foreach (var iteration in Benchmark.Iterations)
            {
                using (iteration.StartMeasurement())
                {
                    for (int i = 0; i < LoadIterations; i++)
                    {
                        InternalParser.TryParseBoolean(utf8ByteSpan, nf, fd, out value, out bytesConsumed);
                    }
                }
            }
        }
Beispiel #2
0
        private unsafe static void InternalParserByteStarToBool(string text)
        {
            bool value;
            int  bytesConsumed;

            byte[]       utf8ByteArray = Encoding.UTF8.GetBytes(text);
            EncodingData fd            = EncodingData.InvariantUtf8;
            TextFormat   nf            = new TextFormat('N');

            foreach (var iteration in Benchmark.Iterations)
            {
                fixed(byte *utf8ByteStar = utf8ByteArray)
                {
                    using (iteration.StartMeasurement())
                    {
                        for (int i = 0; i < LoadIterations; i++)
                        {
                            InternalParser.TryParseBoolean(utf8ByteStar, 0, utf8ByteArray.Length, fd, nf, out value, out bytesConsumed);
                        }
                    }
                }
            }
        }