diff options
author | dotdotisdead <dotdotisdead@a3eca27d-f21b-0410-9b4a-6511e771f64e> | 2007-01-10 13:20:42 +0000 |
---|---|---|
committer | dotdotisdead <dotdotisdead@a3eca27d-f21b-0410-9b4a-6511e771f64e> | 2007-01-10 13:20:42 +0000 |
commit | dd34abf7bac54838473e24d2f8c7eec62646a8cd (patch) | |
tree | 168e155928849f0e9948b4da3988ae949acd1525 | |
parent | c0bb815c7e93362b17c330c975a3032662349bcc (diff) |
Work on tuning tests.
-rwxr-xr-x | xdelta3/setup.py | 7 | ||||
-rwxr-xr-x | xdelta3/xdelta3-main.h | 58 | ||||
-rwxr-xr-x | xdelta3/xdelta3-regtest.py | 133 |
3 files changed, 148 insertions, 50 deletions
diff --git a/xdelta3/setup.py b/xdelta3/setup.py index ffde8ad..84b6cbf 100755 --- a/xdelta3/setup.py +++ b/xdelta3/setup.py | |||
@@ -21,16 +21,19 @@ from distutils.core import setup, Extension | |||
21 | xdelta3_ext = Extension('xdelta3', | 21 | xdelta3_ext = Extension('xdelta3', |
22 | ['xdelta3.c'], | 22 | ['xdelta3.c'], |
23 | define_macros = [ | 23 | define_macros = [ |
24 | ('EXTCOMP',1), | ||
25 | ('REGRESSION_TEST',1), | 24 | ('REGRESSION_TEST',1), |
26 | ('SECONDARY_DJW',1), | 25 | ('SECONDARY_DJW',1), |
27 | ('SECONDARY_FGK',1), | 26 | ('SECONDARY_FGK',1), |
28 | ('VCDIFF_TOOLS',1), | 27 | ('VCDIFF_TOOLS',1), |
29 | ('XD3_DEBUG',1), | 28 | ('XD3_DEBUG',1), |
30 | ('XD3_POSIX',1), | 29 | ('XD3_POSIX',1), |
30 | ('EXTERNAL_COMPRESSION',1), | ||
31 | ('XD3_USE_LARGEFILE64',1), | 31 | ('XD3_USE_LARGEFILE64',1), |
32 | ('PYTHON_MODULE',1), | 32 | ('PYTHON_MODULE',1), |
33 | ]) | 33 | ], |
34 | extra_compile_args = [ '-O3', | ||
35 | '-funroll-loops', | ||
36 | ]) | ||
34 | 37 | ||
35 | # $Format: "REL='$Xdelta3Version$'" $ | 38 | # $Format: "REL='$Xdelta3Version$'" $ |
36 | REL='0k' | 39 | REL='0k' |
diff --git a/xdelta3/xdelta3-main.h b/xdelta3/xdelta3-main.h index e80b332..7d03eb7 100755 --- a/xdelta3/xdelta3-main.h +++ b/xdelta3/xdelta3-main.h | |||
@@ -242,7 +242,7 @@ static int option_stdout = 0; | |||
242 | static int option_force = 0; | 242 | static int option_force = 0; |
243 | static int option_verbose = 0; | 243 | static int option_verbose = 0; |
244 | static int option_quiet = 0; | 244 | static int option_quiet = 0; |
245 | static int option_level = 6; | 245 | static int option_level = 5; |
246 | static int option_use_appheader = 1; | 246 | static int option_use_appheader = 1; |
247 | static uint8_t* option_appheader = NULL; | 247 | static uint8_t* option_appheader = NULL; |
248 | static int option_use_secondary = /* until-standardized, leave this off */ 0; | 248 | static int option_use_secondary = /* until-standardized, leave this off */ 0; |
@@ -352,6 +352,51 @@ main_config (void) | |||
352 | return EXIT_SUCCESS; | 352 | return EXIT_SUCCESS; |
353 | } | 353 | } |
354 | 354 | ||
355 | static void | ||
356 | reset_defaults() | ||
357 | { | ||
358 | option_stdout = 0; | ||
359 | option_force = 0; | ||
360 | option_verbose = 0; | ||
361 | option_quiet = 0; | ||
362 | option_level = 5; | ||
363 | option_use_appheader = 1; | ||
364 | option_appheader = NULL; | ||
365 | option_use_secondary = 0; | ||
366 | option_secondary = NULL; | ||
367 | option_use_checksum = 1; | ||
368 | option_use_altcodetable = 0; | ||
369 | option_smatch_config = NULL; | ||
370 | option_no_compress = 0; | ||
371 | option_no_output = 0; | ||
372 | option_source_filename = NULL; | ||
373 | option_winsize = XD3_DEFAULT_WINSIZE; | ||
374 | option_srcwinsz = XD3_DEFAULT_SRCWINSZ; | ||
375 | option_srcwinsz_set = 0; | ||
376 | option_profile_cnt = 0; | ||
377 | #if EXTERNAL_COMPRESSION | ||
378 | option_decompress_inputs = 1; | ||
379 | option_recompress_outputs = 1; | ||
380 | #endif | ||
381 | #if VCDIFF_TOOLS | ||
382 | option_print_cpymode = 1; | ||
383 | #endif | ||
384 | program_name = NULL; | ||
385 | appheader_used = NULL; | ||
386 | main_bdata = NULL; | ||
387 | lru_size = 0; | ||
388 | lru = NULL; | ||
389 | do_not_lru = 0; | ||
390 | lru_hits = 0; | ||
391 | lru_misses = 0; | ||
392 | lru_filled = 0; | ||
393 | allow_fake_source = 0; | ||
394 | option_winsize = XD3_DEFAULT_WINSIZE; | ||
395 | option_srcwinsz = XD3_DEFAULT_SRCWINSZ; | ||
396 | option_srcwinsz_set = 0; | ||
397 | option_smatch_config = NULL; | ||
398 | } | ||
399 | |||
355 | static void* | 400 | static void* |
356 | main_malloc1 (usize_t size) | 401 | main_malloc1 (usize_t size) |
357 | { | 402 | { |
@@ -2295,8 +2340,8 @@ main_input (xd3_cmd cmd, | |||
2295 | config.smatcher_soft.long_enough = values[8]; | 2340 | config.smatcher_soft.long_enough = values[8]; |
2296 | config.smatcher_soft.promote = values[9]; | 2341 | config.smatcher_soft.promote = values[9]; |
2297 | } | 2342 | } |
2298 | else if (option_level < 5) { config.smatch_cfg = XD3_SMATCH_FAST; } | 2343 | else if (option_level <= 5) { config.smatch_cfg = XD3_SMATCH_FAST; } |
2299 | else { config.smatch_cfg = XD3_SMATCH_SLOW; } | 2344 | else { config.smatch_cfg = XD3_SMATCH_SLOW; } |
2300 | break; | 2345 | break; |
2301 | #endif | 2346 | #endif |
2302 | case CMD_DECODE: | 2347 | case CMD_DECODE: |
@@ -2353,6 +2398,11 @@ main_input (xd3_cmd cmd, | |||
2353 | return EXIT_FAILURE; | 2398 | return EXIT_FAILURE; |
2354 | } | 2399 | } |
2355 | 2400 | ||
2401 | if (option_verbose > 1) | ||
2402 | { | ||
2403 | XPR(NT "scanner configuration: %s\n", stream.smatcher.name); | ||
2404 | } | ||
2405 | |||
2356 | /* This times each window. */ | 2406 | /* This times each window. */ |
2357 | get_millisecs_since (); | 2407 | get_millisecs_since (); |
2358 | 2408 | ||
@@ -2661,6 +2711,8 @@ main (int argc, char **argv) | |||
2661 | main_file_init (& ofile); | 2711 | main_file_init (& ofile); |
2662 | main_file_init (& sfile); | 2712 | main_file_init (& sfile); |
2663 | 2713 | ||
2714 | reset_defaults(); | ||
2715 | |||
2664 | go: /* Go. */ | 2716 | go: /* Go. */ |
2665 | cmd = CMD_NONE; | 2717 | cmd = CMD_NONE; |
2666 | sfilename = NULL; | 2718 | sfilename = NULL; |
diff --git a/xdelta3/xdelta3-regtest.py b/xdelta3/xdelta3-regtest.py index 4cb3a35..bf1693d 100755 --- a/xdelta3/xdelta3-regtest.py +++ b/xdelta3/xdelta3-regtest.py | |||
@@ -560,50 +560,89 @@ def ReportSpeed(L,tr,desc): | |||
560 | (desc, L, tr.r1.dsize, tr.time.mean * 1000.0, ((L+tr.r1.dsize) / tr.time.mean), tr.trials, tr.reps) | 560 | (desc, L, tr.r1.dsize, tr.time.mean * 1000.0, ((L+tr.r1.dsize) / tr.time.mean), tr.trials, tr.reps) |
561 | 561 | ||
562 | def BigFileRuns(rcsf): | 562 | def BigFileRuns(rcsf): |
563 | while 1: | ||
564 | |||
565 | rand = random.Random() | ||
566 | f1 = open(TMPDIR + "/big.1", "w") | ||
567 | f2 = open(TMPDIR + "/big.2", "w") | ||
568 | f1sz = 0 | ||
569 | f2sz = 0 | ||
570 | for file in rcsf.rcsfiles: | ||
571 | if file.versions < 2: | ||
572 | continue | ||
573 | r1 = 0 | ||
574 | r2 = 0 | ||
575 | while r1 == r2: | ||
576 | r1 = rand.randint(0, len(file.versions) - 1) | ||
577 | r2 = rand.randint(0, len(file.versions) - 1) | ||
578 | f1sz += file.AppendVersion(f1, r1) | ||
579 | f2sz += file.AppendVersion(f2, r2) | ||
580 | |||
581 | f1.close() | ||
582 | f2.close() | ||
583 | |||
584 | print "Test input sizes: %d %d" % (f1sz, f2sz) | ||
585 | |||
586 | BigFileRun(TMPDIR + "/big.1", | ||
587 | TMPDIR + "/big.2") | ||
588 | #continue | ||
589 | #end | ||
590 | |||
591 | def BigFileRun(f1, f2): | ||
592 | |||
593 | testcases = [ | ||
594 | # large_look large_step small_look small_chain small_lchain | ||
595 | # ssmatch try_lazy max_lazy long_enough promote | ||
596 | ['-DC', '16,32,4,2,2,1,0,0,64,0'], | ||
597 | ['-DC', '24,32,4,2,2,1,0,0,64,0'], | ||
598 | ['-DC', '32,32,4,2,2,1,0,0,64,0'], | ||
599 | ] | ||
600 | |||
601 | for test in testcases: | ||
602 | runner = Xdelta3Pair() | ||
603 | runner.extra = ['-DC', test] | ||
604 | result = TimeRun(runner.Runner(f1, 1, f2, 2)) | ||
605 | |||
606 | print 'test %s dsize %d: time %.7f: in %u/%u trials' % \ | ||
607 | (test, | ||
608 | result.r1.dsize, | ||
609 | result.time.mean, | ||
610 | result.trials, | ||
611 | result.reps) | ||
612 | #end | ||
613 | return 1 | ||
614 | |||
615 | def RandomBigRun(f1, f2): | ||
616 | |||
617 | input_ranges = [ | ||
618 | (8, 32, 4), | ||
619 | (8, 64, 8), | ||
620 | (4, 6, 1), | ||
621 | (1, 8, 1), | ||
622 | (1, 4, 1), | ||
623 | (0, 1, 1), | ||
624 | (0, 1, 1), | ||
625 | (8, 128, 32), | ||
626 | (8, 128, 32), | ||
627 | (0, 1, 1), | ||
628 | ] | ||
629 | |||
630 | config = [] | ||
563 | rand = random.Random() | 631 | rand = random.Random() |
564 | f1 = open(TMPDIR + "/big.1", "w") | ||
565 | f2 = open(TMPDIR + "/big.2", "w") | ||
566 | f1sz = 0 | ||
567 | f2sz = 0 | ||
568 | for file in rcsf.rcsfiles: | ||
569 | if file.versions < 2: | ||
570 | continue | ||
571 | r1 = 0 | ||
572 | r2 = 0 | ||
573 | while r1 == r2: | ||
574 | r1 = rand.randint(0, len(file.versions) - 1) | ||
575 | r2 = rand.randint(0, len(file.versions) - 1) | ||
576 | f1sz += file.AppendVersion(f1, r1) | ||
577 | f2sz += file.AppendVersion(f2, r2) | ||
578 | |||
579 | f1.close() | ||
580 | f2.close() | ||
581 | |||
582 | print "Test input sizes: %d %d" % (f1sz, f2sz) | ||
583 | 632 | ||
584 | while 1: | 633 | for input in input_ranges: |
634 | config.append(str(rand.randrange(input[0], input[1] + 1, input[2]))) | ||
585 | 635 | ||
586 | extras = [ | 636 | runner = Xdelta3Pair() |
587 | ['-1'], | 637 | runner.extra = ['-DC', ','.join(config)] |
588 | ['-C', '32,32,4,2,2,1,0,0,64,0'], | 638 | result = TimeRun(runner.Runner(f1, 1, f2, 2)) |
589 | ['-9'], | 639 | |
590 | ['-C', '64,64,4,128,16,0,1,8,128,0'], | 640 | print 'test %s dsize %d: time %.7f: in %u/%u trials' % \ |
591 | ] | 641 | (','.join(config), |
592 | 642 | result.r1.dsize, | |
593 | for extra in extras: | 643 | result.time.mean, |
594 | runner = Xdelta3Pair() | 644 | result.trials, |
595 | runner.extra = extra | 645 | result.reps) |
596 | result = TimeRun(runner.Runner(TMPDIR + "/big.1", 1, | ||
597 | TMPDIR + "/big.2", 2)) | ||
598 | |||
599 | print 'testing %s dsize %d: time %.7f: in %u/%u trials' % \ | ||
600 | (extra, | ||
601 | result.r1.dsize, | ||
602 | result.time.mean, | ||
603 | result.trials, | ||
604 | result.reps) | ||
605 | # continue | ||
606 | # end | ||
607 | 646 | ||
608 | def RunSpeed(): | 647 | def RunSpeed(): |
609 | for L in Decimals(MAX_RUN): | 648 | for L in Decimals(MAX_RUN): |
@@ -616,11 +655,15 @@ def RunSpeed(): | |||
616 | if __name__ == "__main__": | 655 | if __name__ == "__main__": |
617 | try: | 656 | try: |
618 | os.mkdir(TMPDIR) | 657 | os.mkdir(TMPDIR) |
619 | rcsf = Test() | 658 | #rcsf = Test() |
620 | #rcsf.PairsByDate(Xdelta3Pair()) | 659 | #rcsf.PairsByDate(Xdelta3Pair()) |
621 | #RunSpeed() | 660 | #RunSpeed() |
622 | BigFileRuns(rcsf) | 661 | #BigFileRuns(rcsf) |
662 | #BigFileRun("/tmp/big.1", "/tmp/big.2") | ||
663 | while 1: | ||
664 | RandomBigRun("/tmp/big.1", "/tmp/big.2") | ||
623 | except CommandError: | 665 | except CommandError: |
624 | pass | 666 | pass |
625 | 667 | else: | |
626 | RunCommand(['rm', '-rf', TMPDIR]) | 668 | #RunCommand(['rm', '-rf', TMPDIR]) |
669 | pass | ||