public void TestPerf() { using (FileStream stream = File.Open(LongFile, FileMode.Open, FileAccess.Read)) { var decoder = new FastDecoder(_context,new BufferedStream(stream,65535)); foreach (Message msg in decoder) { var type = (char) msg.GetInt(0); string symbol = msg.GetString(1); int t = msg.GetInt(2); string exch = msg.GetString(3); var seqNum = (uint) msg.GetInt(4); int v5 = msg.GetInt(5); var v6 = (uint) msg.GetInt(6); int dt = msg.GetInt(7); int v8 = msg.GetInt(8); var itemType = (uint) msg.GetInt(9); int v10 = msg.GetInt(10); if (type == 'Q') { string v11 = msg.GetString(11); int v12 = msg.GetInt(12); var v13 = (uint) msg.GetInt(13); } } } }
public void SetUp() { _output = new PipedStream(); _input = new PipedStream(_output); _encodingContext = new Context(); _decodingContext = new Context(); _encoder = new FastEncoder(_encodingContext); _decoder = new FastDecoder(_decodingContext, _input); }
public void SetUp() { output = new PipedStream(); input = new PipedStream(output); encodingContext = new Context(); decodingContext = new Context(); encoder = new FastEncoder(encodingContext); decoder = new FastDecoder(decodingContext, input); }
public void TestDecode() { // --PMAP-- --TID--- ---#1--- --PMAP-- --TID--- ------------#1------------ ------------#3------------ const string encoding = "11000000 10000001 10001111 11000000 10000010 01001001 01000010 11001101 10000000 00000000 11100110"; var decoder = new FastDecoder(_context, BitStream(encoding)); Message readMessage = decoder.ReadMessage(); Assert.AreEqual(_message, readMessage); }
public void TestDecodeEmptyMessage() { var messageTemplate = new MessageTemplate("", new Field[0]); Stream input = ByteUtil.CreateByteStream("11000000 11110001"); var context = new Context(); context.RegisterTemplate(113, messageTemplate); Message message = new FastDecoder(context, input).ReadMessage(); Assert.AreEqual(113, message.GetInt(0)); }
public void TestDecodeMessageWithSignedIntegerFieldTypesAndAllOperators() { var template = new MessageTemplate( "", new Field[] { new Scalar("1", FastType.I32, Operator.Copy, ScalarValue.Undefined, false), new Scalar("2", FastType.I32, Operator.Delta, ScalarValue.Undefined, false), new Scalar("3", FastType.I32, Operator.Increment, new IntegerValue(10), false), new Scalar("4", FastType.I32, Operator.Increment, ScalarValue.Undefined, false), new Scalar("5", FastType.I32, Operator.Constant, new IntegerValue(1), false), /* NON-TRANSFERRABLE */ new Scalar("6", FastType.I32, Operator.Default, new IntegerValue(2), false) }); GroupValue message = new Message(template); message.SetInteger(1, 109); message.SetInteger(2, 29470); message.SetInteger(3, 10); message.SetInteger(4, 3); message.SetInteger(5, 1); message.SetInteger(6, 2); // --PMAP-- --TID--- --------#1------- ------------#2------------ ---#4--- const string msg1 = "11101000 11110001 00000000 11101101 00000001 01100110 10011110 10000011"; // --PMAP-- ---#2--- ---#6--- const string msg2 = "10000100 11111111 10000011"; // --PMAP-- --------#1------- --------#2------- ---#4--- ---#6--- const string msg3 = "10101100 00000000 11100000 00001000 10000111 10000001 10000011"; Stream input = ByteUtil.CreateByteStream(msg1 + ' ' + msg2 + ' ' + msg3); var context = new Context(); context.RegisterTemplate(113, template); var decoder = new FastDecoder(context, input); Message readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); message.SetInteger(2, 29469); message.SetInteger(3, 11); message.SetInteger(4, 4); message.SetInteger(6, 3); readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); message.SetInteger(1, 96); message.SetInteger(2, 30500); message.SetInteger(3, 12); message.SetInteger(4, 1); readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); }
public void TestDecodeSimpleMessage() { var template = new MessageTemplate( "", new Field[] { new Scalar("1", FastType.U32, Operator.Copy, ScalarValue.Undefined, false) }); Stream input = ByteUtil.CreateByteStream("11100000 11110001 10000001"); var context = new Context(); context.RegisterTemplate(113, template); var message = new Message(template); message.SetInteger(1, 1); var decoder = new FastDecoder(context, input); GroupValue readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); Assert.AreEqual(readMessage, message); }
public void TestDecodeSequentialEmptyMessages() { var messageTemplate = new MessageTemplate("", new Field[0]); Stream input = ByteUtil.CreateByteStream("11000000 11110001 10000000"); var context = new Context(); context.RegisterTemplate(113, messageTemplate); var decoder = new FastDecoder(context, input); GroupValue message = decoder.ReadMessage(); GroupValue message2 = decoder.ReadMessage(); Assert.AreEqual(113, message.GetInt(0)); Assert.AreEqual(113, message2.GetInt(0)); }
public void TestDecodeMessageWithStringFieldTypesAndAllOperators() { var template = new MessageTemplate( "", new Field[] { new Scalar("1", FastType.Ascii, Operator.Copy, ScalarValue.Undefined, false), new Scalar("2", FastType.Ascii, Operator.Delta, ScalarValue.Undefined, false), new Scalar("3", FastType.Ascii, Operator.Constant, new StringValue("e"), false), /* NON-TRANSFERRABLE */ new Scalar("4", FastType.Ascii, Operator.Default, new StringValue("long"), false) }); var message = new Message(template); message.SetString(1, "on"); message.SetString(2, "DCB32"); message.SetString(3, "e"); message.SetString(4, "long"); // --PMAP-- --TID--- --------#1------- ---------------------#2--------------------- const string msg1 = "11100000 11110001 01101111 11101110 10000000 01000100 01000011 01000010 00110011 10110010"; // --PMAP-- ------------#2------------ ---------------------#4--------------------- const string msg2 = "10010000 10000010 00110001 10110110 01110011 01101000 01101111 01110010 11110100"; Stream input = ByteUtil.CreateByteStream(msg1 + ' ' + msg2); var context = new Context(); context.RegisterTemplate(113, template); var decoder = new FastDecoder(context, input); Message readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); message.SetString(2, "DCB16"); message.SetString(4, "short"); readMessage = decoder.ReadMessage(); Assert.AreEqual(message, readMessage); }
public MessageInputStream(Stream inputStream, Context context) { _inStream = inputStream; _context = context; _decoder = new FastDecoder(context, _inStream); }
public void TestGroupWithoutPresenceMap() { MessageTemplate template = Template( "<template>" + " <group name='priceGroup' presence='optional'>" + " <decimal name='price'><delta/></decimal>" + " </group>" + "</template>"); var encodingContext = new Context(); var decodingContext = new Context(); encodingContext.RegisterTemplate(1, template); decodingContext.RegisterTemplate(1, template); const string encodedBits = "11100000 10000001 11111110 10111111"; var decoder = new FastDecoder(decodingContext, new MemoryStream(ByteUtil.ConvertBitStringToFastByteArray(encodedBits))); Message message = decoder.ReadMessage(); Assert.AreEqual(0.63, message.GetGroup("priceGroup").GetDouble("price"), 0.01); byte[] encoding = template.Encode(message, encodingContext); TestUtil.AssertBitVectorEquals(encodedBits, encoding); }