PageRenderTime 61ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/uppdev/sdiff/main.cpp

http://upp-mirror.googlecode.com/
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
  1. #include <Core/Core.h>
  2. String GenString(int len)
  3. {
  4. String result;
  5. while(len--)
  6. result.Cat(255 - rand() % 226);
  7. return result;
  8. }
  9. void Main()
  10. {
  11. String master = LoadFile("e:\\file1.txt");
  12. String data = LoadFile("e:\\file2.txt");
  13. TimeStop();
  14. // LOG("Test");
  15. // RDUMP(TimeStop());
  16. // RDUMP(DiffPack(master, data).GetLength());
  17. TimeStop();
  18. for(int i = 0; i < 10; i++)
  19. {
  20. RDUMP(DiffPack(master, data).GetLength());
  21. // ASSERT(DiffUnpack(master, pack) == data);
  22. }
  23. RDUMP(TimeStop());
  24. String s = GenString(500000);
  25. String z = String(0, 1000000);
  26. TimeStop();
  27. RDUMP(DiffPack(s, s + s).GetLength());
  28. RDUMP(TimeStop());
  29. RDUMP(DiffPack(z, z).GetLength());
  30. RDUMP(TimeStop());
  31. int q = 0;
  32. for(;;) {
  33. if(q++ % 1000)
  34. printf("%d\r\n", q);
  35. if(rand() % 5 == 0)
  36. master = data;
  37. int n = rand() % 50;
  38. if(rand() & 1)
  39. data.Insert(rand() % data.GetLength(), GenString(n));
  40. else {
  41. if(n < data.GetLength())
  42. data.Remove(rand() % (data.GetLength() - n), n);
  43. }
  44. String pack = DiffPack(master, data);
  45. ASSERT(DiffUnpack(master, pack) == data);
  46. }
  47. }