Esempio n. 1
0
        public void BinaryDiffTest()
        {
//			string pair = "USD_JPY_Huge";
//			string pair = "USD_JPY_YEARS";
            string     pair       = "USD_JPY";
            TickReader tickReader = new TickReader();

            tickReader.LogProgress = true;
            tickReader.Initialize("Test\\DataCache", pair);

            byte[]       previous = new byte[1024];
            MemoryStream stream   = new MemoryStream();

            diffBits = new BitArray(1024);
            long fileSize     = 0;
            long compressSize = 0;

            int count = 0;

            try {
                TickBinary tick   = new TickBinary();
                TickIO     tickIO = new TickImpl();
                while (true)
                {
                    tickReader.ReadQueue.Dequeue(ref tick);
                    stream.Seek(0, SeekOrigin.Begin);
                    tickIO.Inject(tick);
                    tickIO.ToWriter(stream);
                    CompareSignature(stream.GetBuffer(), previous, stream.Position);
                    fileSize += stream.Position;
                    int totDiffLength = 1 + diffLength + diffBits.ByteCount;
                    compressSize += totDiffLength;
                    if (count > 1000 && count < 2000)
                    {
//		                log.WriteFile(ByteArrayToString(memory,stream.Position));
                        if (logging)
                        {
                            log.Debug(count + ": " + totDiffLength + " " + diffLength + " byte " + ByteArrayToString(diffBits.Bytes, diffBits.ByteCount) + " " + ByteArrayToString(diff, diffLength));
                        }
                    }

                    count++;
                    Array.Copy(stream.GetBuffer(), previous, stream.Position);
                }
            } catch (QueueException ex) {
                Assert.AreEqual(EventType.EndHistorical, ex.EntryType);
            } catch (CollectionTerminatedException) {
            }
            TickReader.CloseAll();
            log.Debug("File Size = " + fileSize + ", Compressed Size = " + compressSize);
        }
 public void TearDown()
 {
     TickReader.CloseAll();
 }
 public void Dispose()
 {
     TickReader.CloseAll();
 }