diff options
Diffstat (limited to 'xdelta3')
-rw-r--r-- | xdelta3/Makefile.am | 2 | ||||
-rwxr-xr-x | xdelta3/run_release.sh | 1 | ||||
-rw-r--r-- | xdelta3/testing/checksum_test.cc | 107 |
3 files changed, 61 insertions, 49 deletions
diff --git a/xdelta3/Makefile.am b/xdelta3/Makefile.am index d485333..f589599 100644 --- a/xdelta3/Makefile.am +++ b/xdelta3/Makefile.am | |||
@@ -42,7 +42,7 @@ xdelta3checksum_SOURCES = $(common_SOURCES) \ | |||
42 | # Note: for extra sanity checks, enable -Wconversion. Note there | 42 | # Note: for extra sanity checks, enable -Wconversion. Note there |
43 | # are a lot of false positives. | 43 | # are a lot of false positives. |
44 | WFLAGS = -Wall -Wshadow -fno-builtin -Wextra -Wsign-compare \ | 44 | WFLAGS = -Wall -Wshadow -fno-builtin -Wextra -Wsign-compare \ |
45 | -Wno-unused-parameter # -Wconversion | 45 | -Wno-unused-parameter -Wformat # -Wconversion |
46 | 46 | ||
47 | 47 | ||
48 | C_WFLAGS = $(WFLAGS) -pedantic -std=c99 | 48 | C_WFLAGS = $(WFLAGS) -pedantic -std=c99 |
diff --git a/xdelta3/run_release.sh b/xdelta3/run_release.sh index 21ae8fb..4266af4 100755 --- a/xdelta3/run_release.sh +++ b/xdelta3/run_release.sh | |||
@@ -53,6 +53,7 @@ function buildit { | |||
53 | D=build/$MACH/${sizebits}size-${offsetbits}off | 53 | D=build/$MACH/${sizebits}size-${offsetbits}off |
54 | mkdir -p $D | 54 | mkdir -p $D |
55 | (cd $D && $SRCDIR/configure --prefix=$PWD/bin --enable-debug-symbols) | 55 | (cd $D && $SRCDIR/configure --prefix=$PWD/bin --enable-debug-symbols) |
56 | (cd $D && make xdelta3checksum) | ||
56 | } | 57 | } |
57 | 58 | ||
58 | function buildall { | 59 | function buildall { |
diff --git a/xdelta3/testing/checksum_test.cc b/xdelta3/testing/checksum_test.cc index 1643c9f..5b57a49 100644 --- a/xdelta3/testing/checksum_test.cc +++ b/xdelta3/testing/checksum_test.cc | |||
@@ -38,8 +38,8 @@ uint64_t good_64bit_values[] = { | |||
38 | void print_header() { | 38 | void print_header() { |
39 | static int hdr_cnt = 0; | 39 | static int hdr_cnt = 0; |
40 | if (hdr_cnt++ % 20 == 0) { | 40 | if (hdr_cnt++ % 20 == 0) { |
41 | printf("Name\t\t\t\tConf\t\tCount\tUniq\tFull\tCover\tColls" | 41 | printf("%-32sConf\t\tCount\tUniq\tFull\tCover\tColls" |
42 | "\tMB/s\tIters\t#Colls\n"); | 42 | "\tMB/s\tIters\t#Colls\n", "Name"); |
43 | } | 43 | } |
44 | } | 44 | } |
45 | 45 | ||
@@ -228,11 +228,10 @@ struct large_cksum_old : public with_stream<SELF> { | |||
228 | 228 | ||
229 | template <typename Word> | 229 | template <typename Word> |
230 | struct file_stats { | 230 | struct file_stats { |
231 | typedef std::list<const uint8_t*> ptr_list; | 231 | typedef const uint8_t* ptr_type; |
232 | typedef Word word_type; | 232 | typedef Word word_type; |
233 | typedef btree::btree_map<word_type, ptr_list> table_type; | 233 | typedef btree::btree_multimap<word_type, ptr_type> table_type; |
234 | typedef typename table_type::iterator table_iterator; | 234 | typedef typename table_type::iterator table_iterator; |
235 | typedef typename ptr_list::iterator ptr_iterator; | ||
236 | 235 | ||
237 | usize_t cksum_size; | 236 | usize_t cksum_size; |
238 | usize_t cksum_skip; | 237 | usize_t cksum_skip; |
@@ -256,40 +255,34 @@ struct file_stats { | |||
256 | table.clear(); | 255 | table.clear(); |
257 | } | 256 | } |
258 | 257 | ||
259 | void update(const word_type &word, const uint8_t *ptr) { | 258 | void update(word_type word, ptr_type ptr) { |
260 | table_iterator t_i = table.find(word); | 259 | table_iterator t_i = table.find(word); |
261 | 260 | ||
262 | count++; | 261 | count++; |
263 | 262 | if (t_i != table.end()) { | |
264 | if (t_i == table.end()) { | 263 | int collisions = 0; |
265 | table.insert(std::make_pair(word, ptr_list())); | 264 | for (table_iterator p_i = t_i; |
266 | } | 265 | p_i != table.end() && p_i->first == word; |
267 | 266 | ++p_i) { | |
268 | ptr_list &pl = table[word]; // ??? | 267 | if (memcmp(p_i->second, ptr, cksum_size) == 0) { |
269 | 268 | return; | |
270 | int collisions = 0; | 269 | } |
271 | for (ptr_iterator p_i = pl.begin(); | 270 | collisions++; |
272 | p_i != pl.end(); | ||
273 | ++p_i) { | ||
274 | // TODO !!! Use btree here too duh | ||
275 | if (memcmp(*p_i, ptr, cksum_size) == 0) { | ||
276 | return; | ||
277 | } | 271 | } |
278 | collisions++; | 272 | if (collisions >= 1000) { |
279 | } | ||
280 | if (collisions >= 10000) | ||
281 | { | ||
282 | fprintf(stderr, "Something is not right, lots of collisions=%d\n", | 273 | fprintf(stderr, "Something is not right, lots of collisions=%d\n", |
283 | collisions); | 274 | collisions); |
284 | abort(); | 275 | abort(); |
285 | } | 276 | } |
286 | 277 | } else { | |
278 | unique_values++; | ||
279 | } | ||
287 | unique++; | 280 | unique++; |
288 | pl.push_back(ptr); | 281 | table.insert(std::make_pair(word, ptr)); |
282 | return; | ||
289 | } | 283 | } |
290 | 284 | ||
291 | void freeze() { | 285 | void freeze() { |
292 | unique_values = table.size(); | ||
293 | table.clear(); | 286 | table.clear(); |
294 | } | 287 | } |
295 | }; | 288 | }; |
@@ -459,7 +452,8 @@ struct test_result : public test_result_base { | |||
459 | abort(); | 452 | abort(); |
460 | } | 453 | } |
461 | print_header(); | 454 | print_header(); |
462 | printf("%s\t%d/%d 2^%d\t%u\t%0.4f\t%.4f\t%.4f\t%.1e\t%.2f\t%u\t%u\n", | 455 | printf("%-32s%d/%d 2^%" Z "\t%" Z "\t%0.4f\t%.4f\t%.4f\t%.1e\t%.2f\t" |
456 | "%" Z "\t%" Z "\n", | ||
463 | test_name, | 457 | test_name, |
464 | Checksum::cksum_size, | 458 | Checksum::cksum_size, |
465 | Checksum::cksum_skip, | 459 | Checksum::cksum_skip, |
@@ -607,17 +601,6 @@ struct test_result : public test_result_base { | |||
607 | } | 601 | } |
608 | }; | 602 | }; |
609 | 603 | ||
610 | template <typename Word> | ||
611 | void print_array(const char *tname) { | ||
612 | printf("static const %s hash_multiplier[64] = {\n", tname); | ||
613 | Word p = 1; | ||
614 | for (int i = 0; i < 64; i++) { | ||
615 | printf(" %uU,\n", p); | ||
616 | p *= good_word<Word>(); | ||
617 | } | ||
618 | printf("};\n", tname); | ||
619 | } | ||
620 | |||
621 | static int read_whole_file(const char *name, | 604 | static int read_whole_file(const char *name, |
622 | uint8_t **buf_ptr, | 605 | uint8_t **buf_ptr, |
623 | size_t *buf_len) { | 606 | size_t *buf_len) { |
@@ -677,15 +660,43 @@ int main(int argc, char** argv) { | |||
677 | #define TESTS(SIZE, SKIP) \ | 660 | #define TESTS(SIZE, SKIP) \ |
678 | TEST(usize_t, SIZE, SKIP, 1); \ | 661 | TEST(usize_t, SIZE, SKIP, 1); \ |
679 | TEST(usize_t, SIZE, SKIP, 2) | 662 | TEST(usize_t, SIZE, SKIP, 2) |
680 | 663 | ||
664 | TESTS(5, 1); | ||
665 | TESTS(6, 1); | ||
666 | TESTS(7, 1); | ||
667 | TESTS(8, 1); | ||
681 | TESTS(9, 1); | 668 | TESTS(9, 1); |
682 | // TESTS(9, 9); | 669 | TESTS(10, 1); |
683 | // TESTS(15, 1); | 670 | TESTS(11, 1); |
684 | // TESTS(15, 15); | 671 | TESTS(12, 1); |
685 | // TESTS(127, 1); | 672 | TESTS(13, 1); |
686 | // TESTS(127, 127); | 673 | TESTS(14, 1); |
687 | // TESTS(211, 1); | 674 | TESTS(15, 1); |
688 | // TESTS(211, 211); | 675 | TESTS(16, 1); |
676 | TESTS(17, 1); | ||
677 | TESTS(18, 1); | ||
678 | TESTS(19, 1); | ||
679 | TESTS(20, 1); | ||
680 | TESTS(21, 1); | ||
681 | TESTS(22, 1); | ||
682 | TESTS(23, 1); | ||
683 | TESTS(24, 1); | ||
684 | TESTS(25, 1); | ||
685 | TESTS(26, 1); | ||
686 | TESTS(27, 1); | ||
687 | TESTS(28, 1); | ||
688 | TESTS(29, 1); | ||
689 | TESTS(30, 1); | ||
690 | TESTS(31, 1); | ||
691 | TESTS(32, 1); | ||
692 | TESTS(33, 1); | ||
693 | TESTS(34, 1); | ||
694 | TESTS(35, 1); | ||
695 | TESTS(36, 1); | ||
696 | TESTS(37, 1); | ||
697 | TESTS(38, 1); | ||
698 | TESTS(39, 1); | ||
699 | |||
689 | 700 | ||
690 | for (i = 1; i < argc; i++) { | 701 | for (i = 1; i < argc; i++) { |
691 | if ((ret = read_whole_file(argv[i], | 702 | if ((ret = read_whole_file(argv[i], |
@@ -705,7 +716,7 @@ int main(int argc, char** argv) { | |||
705 | test_result_base *test = *iter; | 716 | test_result_base *test = *iter; |
706 | test->reset(); | 717 | test->reset(); |
707 | 718 | ||
708 | usize_t iters = 1; // TODO | 719 | usize_t iters = 1; |
709 | long start_test = get_millisecs_now(); | 720 | long start_test = get_millisecs_now(); |
710 | 721 | ||
711 | do { | 722 | do { |