summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xxdelta3/xdelta3-regtest.py72
1 files changed, 49 insertions, 23 deletions
diff --git a/xdelta3/xdelta3-regtest.py b/xdelta3/xdelta3-regtest.py
index 656d617..03d3a2e 100755
--- a/xdelta3/xdelta3-regtest.py
+++ b/xdelta3/xdelta3-regtest.py
@@ -47,7 +47,8 @@ MAX_RUN = 1000 * 1000 * 10
47# 47#
48# 48#
49RCSDIR = '/mnt/polaroid/Polaroid/orbit_linux/home/jmacd/PRCS' 49RCSDIR = '/mnt/polaroid/Polaroid/orbit_linux/home/jmacd/PRCS'
50#RCSDIR = 'Z:/Polaroid/orbit_linux/home/jmacd/PRCS' 50RCSDIR = '/tmp/PRCS_read_copy'
51#RCSDIR = 'G:/jmacd/PRCS'
51 52
52TMPDIR = '/tmp/xd3regtest.%d' % os.getpid() 53TMPDIR = '/tmp/xd3regtest.%d' % os.getpid()
53 54
@@ -619,7 +620,8 @@ def BigFileRun(f1, f2):
619 return 1 620 return 1
620 621
621class RandomTestResult: 622class RandomTestResult:
622 def __init__(self, config, runtime, compsize): 623 def __init__(self, round, config, runtime, compsize):
624 self.round = round
623 self.myconfig = config 625 self.myconfig = config
624 self.runtime = runtime 626 self.runtime = runtime
625 self.compsize = compsize 627 self.compsize = compsize
@@ -652,18 +654,22 @@ def PosInAlist(l, e):
652#end 654#end
653 655
654# How many results per round 656# How many results per round
655MAX_RESULTS = 20 657MAX_RESULTS = 500
656 658
657class RandomTester: 659class RandomTester:
658 def __init__(self): 660 def __init__(self, old_results):
661 self.old_configs = old_results
659 self.results = [] 662 self.results = []
663 self.trial_num = 0
664 self.round_num = 0
665 self.random = random.Random()
660 #end 666 #end
661 667
662 def HasEnoughResults(self): 668 def HasEnoughResults(self):
663 return len(self.results) >= MAX_RESULTS 669 return len(self.results) >= MAX_RESULTS
664 #end 670 #end
665 671
666 def RandomBigRun(self, f1, f2): 672 def RandomConfig(self):
667 673
668 input_ranges = [ 674 input_ranges = [
669 (7, 9, 12, 'large_look'), 675 (7, 9, 12, 'large_look'),
@@ -679,7 +685,6 @@ class RandomTester:
679 ] 685 ]
680 686
681 config = [] 687 config = []
682 rand = random.Random()
683 map = {} 688 map = {}
684 689
685 for input in input_ranges: 690 for input in input_ranges:
@@ -692,7 +697,7 @@ class RandomTester:
692 else: 697 else:
693 val = -1 698 val = -1
694 while val < minv or val > maxv: 699 while val < minv or val > maxv:
695 val = int(rand.expovariate(1.0 / mean)) 700 val = int(self.random.expovariate(1.0 / mean))
696 #end 701 #end
697 #end 702 #end
698 703
@@ -701,28 +706,44 @@ class RandomTester:
701 #end 706 #end
702 707
703 if map['small_chain'] < map['small_lchain']: 708 if map['small_chain'] < map['small_lchain']:
704 return 709 return None
705 710
706 if map['large_look'] < map['small_look']: 711 if map['large_look'] < map['small_look']:
707 return 712 return None
708 713
709 strs = [str(x) for x in config] 714 return config
715
716 def RandomBigRun(self, f1, f2):
717 config = None
718 if len(self.old_configs) > 0:
719 config = self.old_configs[0]
720 self.old_configs = self.old_configs[1:]
721 #end
722
723 while config is None:
724 config = self.RandomConfig()
725 #end
710 726
711 runner = Xdelta3Pair() 727 runner = Xdelta3Pair()
712 runner.extra = ['-I', '0', '-D', '-C', ','.join(strs)] 728 runner.extra = ['-I',
729 '0',
730 '-D',
731 '-C', ','.join([str(x) for x in config])]
713 result = TimeRun(runner.Runner(f1, 1, f2, 2)) 732 result = TimeRun(runner.Runner(f1, 1, f2, 2))
714 733
715 tr = RandomTestResult(config, 734 tr = RandomTestResult(self.round_num,
735 config,
716 result.time.mean, 736 result.time.mean,
717 result.r1.dsize) 737 result.r1.dsize)
718 738
719 self.results.append(tr) 739 self.results.append(tr)
720 740
721 print 'Trial %d: %s in %u trials' % \ 741 print 'Trial %d: %s in %u trials' % \
722 (trial_num++, 742 (self.trial_num,
723 tr, 743 tr,
724 result.trials) 744 result.trials)
725 745
746 self.trial_num += 1
726 return 747 return
727 #end 748 #end
728 749
@@ -754,7 +775,6 @@ class RandomTester:
754 print 'Score %f: %s (%d, %d)' % (score, test, spos, tpos) 775 print 'Score %f: %s (%d, %d)' % (score, test, spos, tpos)
755 #end 776 #end
756 777
757 scored = scored[0:MAX_RESULTS/2]
758 sized = sized[0:MAX_RESULTS/2] 778 sized = sized[0:MAX_RESULTS/2]
759 timed = timed[0:MAX_RESULTS/2] 779 timed = timed[0:MAX_RESULTS/2]
760 780
@@ -767,9 +787,12 @@ class RandomTester:
767 #end 787 #end
768 788
769 self.results = [] 789 self.results = []
770 for (score, test) in scored: 790 r = []
771 self.results.append(test) 791 for (score, test) in scored[0:MAX_RESULTS/2]:
792 r.append(test.config())
772 #end 793 #end
794
795 return r
773 #end 796 #end
774#end 797#end
775 798
@@ -780,22 +803,25 @@ def RunSpeed():
780 ReportSpeed(L,trx,'xdelta3') 803 ReportSpeed(L,trx,'xdelta3')
781 trg = TimeRun(GzipRun1(RUNFILE)) 804 trg = TimeRun(GzipRun1(RUNFILE))
782 ReportSpeed(L,trg,'gzip ') 805 ReportSpeed(L,trg,'gzip ')
806 #end
807#end
783 808
784if __name__ == "__main__": 809if __name__ == "__main__":
785 try: 810 try:
811 RunCommand(['rm', '-rf', TMPDIR])
786 os.mkdir(TMPDIR) 812 os.mkdir(TMPDIR)
787 rcsf = Test() 813 rcsf = Test()
814 configs = []
788 815
789 while 1: 816 while 1:
790 f1, f2 = MakeBigFiles(rcsf) 817 f1, f2 = MakeBigFiles(rcsf)
791 #f1 = '/tmp/big.1' 818 #f1 = '/tmp/big.1'
792 #f2 = '/tmp/big.2' 819 #f2 = '/tmp/big.2'
793 test = RandomTester() 820 test = RandomTester(configs)
794 while 1: 821 while not test.HasEnoughResults():
795 while not test.HasEnoughResults(): 822 test.RandomBigRun(f1, f2)
796 test.RandomBigRun(f1, f2) 823 #end
797 #end 824 configs = test.ScoreTests()
798 test.ScoreTests()
799 #end 825 #end
800 #end 826 #end
801 827
@@ -808,5 +834,5 @@ if __name__ == "__main__":
808 except CommandError: 834 except CommandError:
809 pass 835 pass
810 else: 836 else:
811 #RunCommand(['rm', '-rf', TMPDIR]) 837 RunCommand(['rm', '-rf', TMPDIR])
812 pass 838 pass