示例#1
0
        private string Benchmark(StreamReader sr, out double kbPerSec)
        {
            kbPerSec = 0;
            string rawMsg = sr.ReadLine();

            Stopwatch stopwatch = Stopwatch.StartNew();

            for (int i = 0; i < N_CYCLES; ++i)
            {
                Message msg = new Message(rawMsg);
                if (i % n == 0)
                {
                    progressBar.Increment(1);
                    Application.DoEvents();
                }
                msg.Dispose();
            }
            stopwatch.Stop();

            double performance = 0;

            if (0 != stopwatch.ElapsedMilliseconds)
            {
                performance = Math.Floor((double)N_CYCLES * 1000 / stopwatch.ElapsedMilliseconds);
            }
            kbPerSec = (sr.BaseStream.Length * performance) / 1024;
            return(performance.ToString());
        }
示例#2
0
        private static void ReplayLog(string file, string filter, Session session)
        {
            using (StreamReader sr = new StreamReader(file))
            {
                while (sr.Peek() >= 0)
                {
                    string line = sr.ReadLine();
                    int    messageStartIndex = line.IndexOf("8=FIX.", StringComparison.Ordinal);
                    if (-1 != messageStartIndex)
                    {
                        line = line.Substring(messageStartIndex);
                    }

                    Message msg = new Message(line);
                    if (msg.Type == MsgType.Logon || msg.Type == MsgType.Logout ||
                        msg.Type == MsgType.Heartbeat || msg.Type == MsgType.Test_Request ||
                        msg.Type == MsgType.Resend_Request || msg.Type == MsgType.Sequence_Reset ||
                        msg.Type == MsgType.Reject
                        )
                    {
                        continue;
                    }
                    if ("*" != filter)
                    {
                        if (msg.Type != filter)
                        {
                            continue;
                        }
                    }
                    session.Send(msg);
                }
            }
        }
示例#3
0
        private bool IsStale(FIXForge.NET.FIX.Message message)
        {
            // Simple sending time based filtering of stale messages.
            DateTime previousSendingTime = message.GetTimestamp(Tags.SendingTime).ToUniversalTime();

            TimeSpan keepingTime = TimeSpan.FromMinutes(30);

            bool isStale = (DateTime.UtcNow - previousSendingTime) >= keepingTime;

            return(isStale);

            // More advanced filtering could take into account the message type and/or application-level contents.
        }