/uppdev/sdiff/main.cpp
C++ | 50 lines | 43 code | 3 blank | 4 comment | 9 complexity | 1af92d8cd1c7811b77715dbffd8799f8 MD5 | raw file
Possible License(s): LGPL-2.1, GPL-2.0, BSD-2-Clause, BSD-3-Clause, LGPL-3.0, GPL-3.0
- #include <Core/Core.h>
-
- String GenString(int len)
- {
- String result;
- while(len--)
- result.Cat(255 - rand() % 226);
- return result;
- }
-
- void Main()
- {
- String master = LoadFile("e:\\file1.txt");
- String data = LoadFile("e:\\file2.txt");
- TimeStop();
- // LOG("Test");
- // RDUMP(TimeStop());
- // RDUMP(DiffPack(master, data).GetLength());
- TimeStop();
- for(int i = 0; i < 10; i++)
- {
- RDUMP(DiffPack(master, data).GetLength());
- // ASSERT(DiffUnpack(master, pack) == data);
- }
- RDUMP(TimeStop());
-
- String s = GenString(500000);
- String z = String(0, 1000000);
- TimeStop();
- RDUMP(DiffPack(s, s + s).GetLength());
- RDUMP(TimeStop());
- RDUMP(DiffPack(z, z).GetLength());
- RDUMP(TimeStop());
- int q = 0;
- for(;;) {
- if(q++ % 1000)
- printf("%d\r\n", q);
- if(rand() % 5 == 0)
- master = data;
- int n = rand() % 50;
- if(rand() & 1)
- data.Insert(rand() % data.GetLength(), GenString(n));
- else {
- if(n < data.GetLength())
- data.Remove(rand() % (data.GetLength() - n), n);
- }
- String pack = DiffPack(master, data);
- ASSERT(DiffUnpack(master, pack) == data);
- }
- }