static void test1(string[] args) { ProbaFrame gen = new ProbaFrame(100000000, 0.1); Stream test_frame = gen.generate(); gen.WriteFile("../../test_frame3.txt"); //Stream test_frame = new FileStream("../../test_frame2.txt", FileMode.Open, FileAccess.Read); MemoryStream temp = new MemoryStream(5); using (CoreDumpDeltaWriter <Deflate_Encoder, Deflate_Decoder> test = new CoreDumpDeltaWriter <Deflate_Encoder, Deflate_Decoder>()) { test.Coder = new Deflate_Encoder(); CoderPropID[] propIDs = { CoderPropID.DictionarySize, CoderPropID.PosStateBits, CoderPropID.LitContextBits, CoderPropID.LitPosBits, CoderPropID.Algorithm, CoderPropID.NumFastBytes, CoderPropID.MatchFinder, CoderPropID.EndMarker, }; Int32 dictionary = 1 << 23; Int32 posStateBits = 2; Int32 litContextBits = 0; // for normal files // UInt32 litContextBits = 0; // for 32-bit data Int32 litPosBits = 2; // UInt32 litPosBits = 2; // for 32-bit data Int32 algorithm = 1; Int32 numFastBytes = 128; string mf = "bt4";//match finder bool eos = true; object[] properties = { (Int32)(dictionary), (Int32)(posStateBits), (Int32)(litContextBits), (Int32)(litPosBits), (Int32)(algorithm), (Int32)(numFastBytes), mf, eos, }; //test.Coder.SetCoderProperties(propIDs, properties); File.Delete("../../test_3.LZMA"); test.OpenNewFile("../../test_3.LZMA"); Console.WriteLine("frame de taille : " + test_frame.Length); Stopwatch sw = new Stopwatch(); for (int i = 0; i < n_frame; i++) { Console.WriteLine("frame " + i.ToString()); test_frame.Seek(0, SeekOrigin.Begin); sw.Start(); test.AddFrame(test_frame); sw.Stop(); Console.WriteLine("frame " + i.ToString() + " fait en " + sw.Elapsed); sw.Reset(); } System.Console.WriteLine("fini"); test.FinishTree(); //test.Coder.WriteCoderProperties(temp); } CoreDumpDeltaWriter <Deflate_Encoder, Deflate_Decoder> test2 = new CoreDumpDeltaWriter <Deflate_Encoder, Deflate_Decoder>(); test2.readOnlyOpen("../../test_3.LZMA"); test2.Decoder = new Deflate_Decoder(); //test2.Decoder.SetDecoderProperties(temp.ToArray()); test_retrieve(0, test_frame, test2); test_retrieve(1, test_frame, test2); test_retrieve(53, test_frame, test2); test_retrieve(260, test_frame, test2); test_retrieve(136, test_frame, test2); test_retrieve(n_frame - 1, test_frame, test2); rand_test(100, n_frame, test_frame, test2); while (!Console.KeyAvailable) { ; } }
static void generate_delta_file(string file_name, int n_frame, int frame_size) { ProbaFrame_Delta gen = new ProbaFrame_Delta(frame_size, 0.1, 0.1, 0.00001); Stream test_frame = gen.generate(); using (CoreDumpDeltaWriter <Deflate_Encoder, Deflate_Decoder> test = new CoreDumpDeltaWriter <Deflate_Encoder, Deflate_Decoder>()) { test.Coder = new Deflate_Encoder(); CoderPropID[] propIDs = { CoderPropID.DictionarySize, CoderPropID.PosStateBits, CoderPropID.LitContextBits, CoderPropID.LitPosBits, CoderPropID.Algorithm, CoderPropID.NumFastBytes, CoderPropID.MatchFinder, CoderPropID.EndMarker, }; Int32 dictionary = 1 << 23; Int32 posStateBits = 2; Int32 litContextBits = 0; // for normal files // UInt32 litContextBits = 0; // for 32-bit data Int32 litPosBits = 2; // UInt32 litPosBits = 2; // for 32-bit data Int32 algorithm = 1; Int32 numFastBytes = 128; string mf = "bt4";//match finder bool eos = true; object[] properties = { (Int32)(dictionary), (Int32)(posStateBits), (Int32)(litContextBits), (Int32)(litPosBits), (Int32)(algorithm), (Int32)(numFastBytes), mf, eos, }; //test.Coder.SetCoderProperties(propIDs, properties); File.Delete(file_name); test.OpenNewFile(file_name); Console.WriteLine("frame de taille : " + test_frame.Length); Stopwatch sw = new Stopwatch(); for (int i = 0; i < n_frame; i++) { Console.WriteLine("frame " + i.ToString()); //test_frame.Seek(0, SeekOrigin.Begin); gen.delta_gene(); sw.Start(); test.AddFrame(gen.Frame); sw.Stop(); Console.WriteLine("frame " + i.ToString() + " fait en " + sw.Elapsed); sw.Reset(); } System.Console.WriteLine("fini"); test.FinishTree(); //test.Coder.WriteCoderProperties(temp); } }