diff options
Diffstat (limited to 'xdelta3/xdelta3-regtest.py')
-rwxr-xr-x | xdelta3/xdelta3-regtest.py | 81 |
1 files changed, 40 insertions, 41 deletions
diff --git a/xdelta3/xdelta3-regtest.py b/xdelta3/xdelta3-regtest.py index 928a5f0..8aa03ac 100755 --- a/xdelta3/xdelta3-regtest.py +++ b/xdelta3/xdelta3-regtest.py | |||
@@ -16,12 +16,12 @@ | |||
16 | # along with this program; if not, write to the Free Software | 16 | # along with this program; if not, write to the Free Software |
17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 17 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
18 | 18 | ||
19 | # Under construction. | 19 | # TODO: Test IOPT (1.5 vs. greedy) |
20 | 20 | ||
21 | # TODO: This is really part test, part performance evaluation suite, and | 21 | # TODO: Start testing window sizes |
22 | # really incomplete. | ||
23 | 22 | ||
24 | # TODO: Test IOPT (1.5 vs. greedy) | 23 | # TODO: Note: xd3_encode_memory is underperforming the command-line |
24 | # at run-speed tests (due to excess memory allocation?). Fix. | ||
25 | 25 | ||
26 | import os, sys, math, re, time, types, array, random | 26 | import os, sys, math, re, time, types, array, random |
27 | import xdelta3main | 27 | import xdelta3main |
@@ -85,7 +85,7 @@ def INPUT_SPEC(rand): | |||
85 | RCSDIR = '/tmp/PRCS_read_copy' | 85 | RCSDIR = '/tmp/PRCS_read_copy' |
86 | #RCSDIR = 'G:/jmacd/PRCS' | 86 | #RCSDIR = 'G:/jmacd/PRCS' |
87 | 87 | ||
88 | SAMPLEDIR = "C:/sample_data/WESNOTH_tmp/tar' | 88 | SAMPLEDIR = "C:/sample_data/WESNOTH_tmp/tar" |
89 | 89 | ||
90 | TMPDIR = '/tmp/xd3regtest.%d' % os.getpid() | 90 | TMPDIR = '/tmp/xd3regtest.%d' % os.getpid() |
91 | 91 | ||
@@ -260,14 +260,15 @@ class RcsFile: | |||
260 | os.stat(self.Verf(v+1)).st_size < MIN_SIZE: | 260 | os.stat(self.Verf(v+1)).st_size < MIN_SIZE: |
261 | continue | 261 | continue |
262 | 262 | ||
263 | result = TimeRun(runnable.Runner(self.Verf(v), | 263 | runnable.SetInputs(self.Verf(v), |
264 | self.Vstr(v), | 264 | self.Vstr(v), |
265 | self.Verf(v+1), | 265 | self.Verf(v+1), |
266 | self.Vstr(v+1))) | 266 | self.Vstr(v+1)) |
267 | print 'testing %s %s: ideal %.3f%%: time %.7f: in %u trials' % \ | 267 | result = TimedTest(runnable) |
268 | print 'testing %s %s: ratio %.3f%%: time %.7f: in %u trials' % \ | ||
268 | (os.path.basename(self.fname), | 269 | (os.path.basename(self.fname), |
269 | self.Vstr(v+1), | 270 | self.Vstr(v+1), |
270 | result.r1.ideal, | 271 | result.r1.ratio, |
271 | result.time.mean, | 272 | result.time.mean, |
272 | result.trials) | 273 | result.trials) |
273 | ntrials.append(result) | 274 | ntrials.append(result) |
@@ -370,9 +371,11 @@ class Bucks: | |||
370 | f.write("%.1f %.1f %.1f %d\n" % (i[0],i[1],i[2],i[3])) | 371 | f.write("%.1f %.1f %.1f %d\n" % (i[0],i[1],i[2],i[3])) |
371 | # | 372 | # |
372 | # | 373 | # |
373 | class TimeRun: | 374 | class TimedTest: |
374 | def __init__(self,runnable, | 375 | def __init__(self,runnable, |
375 | skip_trials=SKIP_TRIALS,min_trials=MIN_TRIALS,max_trials=MAX_TRIALS, | 376 | skip_trials=SKIP_TRIALS, |
377 | min_trials=MIN_TRIALS, | ||
378 | max_trials=MAX_TRIALS, | ||
376 | min_stddev_pct=MIN_STDDEV_PCT): | 379 | min_stddev_pct=MIN_STDDEV_PCT): |
377 | 380 | ||
378 | min_trials = min(min_trials,max_trials) | 381 | min_trials = min(min_trials,max_trials) |
@@ -474,7 +477,6 @@ def RunCommand(args): | |||
474 | raise CommandError(args, 'exited %d' % p) | 477 | raise CommandError(args, 'exited %d' % p) |
475 | 478 | ||
476 | def RunCommandIO(args,infn,outfn): | 479 | def RunCommandIO(args,infn,outfn): |
477 | #print "run command io", args | ||
478 | p = os.fork() | 480 | p = os.fork() |
479 | if p == 0: | 481 | if p == 0: |
480 | os.dup2(os.open(infn,os.O_RDONLY),0) | 482 | os.dup2(os.open(infn,os.O_RDONLY),0) |
@@ -488,7 +490,6 @@ def RunCommandIO(args,infn,outfn): | |||
488 | 490 | ||
489 | def RunXdelta3(args): | 491 | def RunXdelta3(args): |
490 | try: | 492 | try: |
491 | #print 'RUN', args | ||
492 | xdelta3main.main(args) | 493 | xdelta3main.main(args) |
493 | except Exception, e: | 494 | except Exception, e: |
494 | raise CommandError(args, "xdelta3.main exception") | 495 | raise CommandError(args, "xdelta3.main exception") |
@@ -500,15 +501,12 @@ class GzipInfo: | |||
500 | 501 | ||
501 | class Xdelta3Info: | 502 | class Xdelta3Info: |
502 | def __init__(self,target,delta): | 503 | def __init__(self,target,delta): |
503 | # TODO: bug is fixed | ||
504 | self.extcomp = 0 # TODO: I removed some code that called printhdr | ||
505 | self.hdrsize = 0 # to compute these, but printhdr uses stdout (now) | ||
506 | self.tgtsize = os.stat(target).st_size | 504 | self.tgtsize = os.stat(target).st_size |
507 | self.dsize = os.stat(delta).st_size | 505 | self.dsize = os.stat(delta).st_size |
508 | if self.tgtsize > 0: | 506 | if self.tgtsize > 0: |
509 | self.ideal = 100.0 * self.dsize / self.tgtsize; | 507 | self.ratio = 100.0 * self.dsize / self.tgtsize; |
510 | else: | 508 | else: |
511 | self.ideal = 0.0 | 509 | self.ratio = 0.0 |
512 | 510 | ||
513 | class Xdelta3ModInfo: | 511 | class Xdelta3ModInfo: |
514 | def __init__(self,target,delta): | 512 | def __init__(self,target,delta): |
@@ -523,20 +521,20 @@ class Xdelta3ModInfo: | |||
523 | self.tgtsize = len(target) | 521 | self.tgtsize = len(target) |
524 | self.dsize = len(delta) | 522 | self.dsize = len(delta) |
525 | if self.tgtsize > 0: | 523 | if self.tgtsize > 0: |
526 | self.ideal = 100.0 * self.dsize / self.tgtsize; | 524 | self.ratio = 100.0 * self.dsize / self.tgtsize; |
527 | else: | 525 | else: |
528 | self.ideal = 0.0 | 526 | self.ratio = 0.0 |
529 | 527 | ||
530 | class Xdelta3Pair: | 528 | class Xdelta3Pair: |
531 | def __init__(self): | 529 | def __init__(self, extra): |
532 | self.type = 'xdelta3' | 530 | self.type = 'xdelta3' |
533 | self.decode_args = '-dqf' | 531 | self.decode_args = '-dqf' |
534 | self.encode_args = '-eqf' | 532 | self.encode_args = '-eqf' |
535 | self.extra = [] | 533 | self.extra = extra |
536 | self.presrc = '-s' | 534 | self.presrc = '-s' |
537 | self.canrep = 1 | 535 | self.canrep = 1 |
538 | 536 | ||
539 | def Runner(self,old,oldv,new,newv): | 537 | def SetInputs(self,old,oldv,new,newv): |
540 | self.old = old | 538 | self.old = old |
541 | self.oldv = oldv | 539 | self.oldv = oldv |
542 | self.new = new | 540 | self.new = new |
@@ -770,7 +768,7 @@ class RandomTester: | |||
770 | return (TMPDIR + "/big.1", | 768 | return (TMPDIR + "/big.1", |
771 | TMPDIR + "/big.2") | 769 | TMPDIR + "/big.2") |
772 | 770 | ||
773 | def RandomBigRun(self, f1, f2): | 771 | def RandomFileTest(self, f1, f2): |
774 | config = None | 772 | config = None |
775 | if len(self.old_configs) > 0: | 773 | if len(self.old_configs) > 0: |
776 | config = self.old_configs[0] | 774 | config = self.old_configs[0] |
@@ -781,9 +779,9 @@ class RandomTester: | |||
781 | config = self.RandomConfig() | 779 | config = self.RandomConfig() |
782 | #end | 780 | #end |
783 | 781 | ||
784 | runner = Xdelta3Pair() | 782 | runner = Xdelta3Pair([ '-C', ','.join([str(x) for x in config]) ]) |
785 | runner.extra = [ '-C', ','.join([str(x) for x in config]) ] | 783 | runner.SetInputs(f1, 1, f2, 2) |
786 | result = TimeRun(runner.Runner(f1, 1, f2, 2)) | 784 | result = TimedTest(runner) |
787 | 785 | ||
788 | tr = RandomTestResult(self.round_num, | 786 | tr = RandomTestResult(self.round_num, |
789 | config, | 787 | config, |
@@ -900,22 +898,24 @@ class RandomTester: | |||
900 | else: | 898 | else: |
901 | stars = ' *' | 899 | stars = ' *' |
902 | print 'Score: %0.6f %s (%.1f%s%s)' % \ | 900 | print 'Score: %0.6f %s (%.1f%s%s)' % \ |
903 | (test.score, test, s / len(all_r), stars, (len(all_r) > 2) and (' in %d' % len(all_r)) or "") | 901 | (test.score, test, s / len(all_r), stars, |
902 | (len(all_r) > 2) and | ||
903 | (' in %d' % len(all_r)) or "") | ||
904 | #end | 904 | #end |
905 | 905 | ||
906 | return r | 906 | return r |
907 | #end | 907 | #end |
908 | #end | 908 | #end |
909 | 909 | ||
910 | # This tests the raw speed of 0-byte inputs | ||
910 | def RunSpeed(): | 911 | def RunSpeed(): |
911 | # TODO: Start testing window sizes | ||
912 | for L in Decimals(MAX_RUN): | 912 | for L in Decimals(MAX_RUN): |
913 | SetFileSize(RUNFILE, L) | 913 | SetFileSize(RUNFILE, L) |
914 | trx = TimeRun(Xdelta3Run1(RUNFILE)) | 914 | trx = TimedTest(Xdelta3Run1(RUNFILE)) |
915 | ReportSpeed(L,trx,'xdelta3') | 915 | ReportSpeed(L,trx,'xdelta3') |
916 | trm = TimeRun(Xdelta3Mod1(RUNFILE)) | 916 | trm = TimedTest(Xdelta3Mod1(RUNFILE)) |
917 | ReportSpeed(L,trm,'module ') | 917 | ReportSpeed(L,trm,'module ') |
918 | trg = TimeRun(GzipRun1(RUNFILE)) | 918 | trg = TimedTest(GzipRun1(RUNFILE)) |
919 | ReportSpeed(L,trg,'gzip ') | 919 | ReportSpeed(L,trg,'gzip ') |
920 | #end | 920 | #end |
921 | #end | 921 | #end |
@@ -924,15 +924,14 @@ if __name__ == "__main__": | |||
924 | try: | 924 | try: |
925 | RunCommand(['rm', '-rf', TMPDIR]) | 925 | RunCommand(['rm', '-rf', TMPDIR]) |
926 | os.mkdir(TMPDIR) | 926 | os.mkdir(TMPDIR) |
927 | #rcsf = Test() | ||
928 | configs = [] | ||
929 | 927 | ||
930 | # This tests pairwise (date-ordered) performance | ||
931 | #rcsf.PairsByDate(Xdelta3Pair()) | ||
932 | |||
933 | # This tests the raw speed of 0-byte inputs | ||
934 | RunSpeed() | 928 | RunSpeed() |
935 | 929 | ||
930 | # This tests pairwise (date-ordered) performance | ||
931 | #rcsf = Test() | ||
932 | #rcsf.PairsByDate(Xdelta3Pair([])) | ||
933 | |||
934 | configs = [] | ||
936 | 935 | ||
937 | while 0: | 936 | while 0: |
938 | #f1 = '/tmp/big.1' | 937 | #f1 = '/tmp/big.1' |
@@ -944,7 +943,7 @@ if __name__ == "__main__": | |||
944 | f2 = '/tmp/WESNOTH_tmp/wesnoth-1.1.13.tar' | 943 | f2 = '/tmp/WESNOTH_tmp/wesnoth-1.1.13.tar' |
945 | #f1 = '/tmp/big.1' | 944 | #f1 = '/tmp/big.1' |
946 | #f2 = '/tmp/big.2' | 945 | #f2 = '/tmp/big.2' |
947 | test.RandomBigRun(f1, f2) | 946 | test.RandomFileTest(f1, f2) |
948 | #end | 947 | #end |
949 | configs = test.ScoreTests() | 948 | configs = test.ScoreTests() |
950 | 949 | ||