summaryrefslogtreecommitdiff
path: root/xdelta3/xdelta3-regtest.py
diff options
context:
space:
mode:
Diffstat (limited to 'xdelta3/xdelta3-regtest.py')
-rwxr-xr-xxdelta3/xdelta3-regtest.py78
1 files changed, 69 insertions, 9 deletions
diff --git a/xdelta3/xdelta3-regtest.py b/xdelta3/xdelta3-regtest.py
index 536c086..4cb3a35 100755
--- a/xdelta3/xdelta3-regtest.py
+++ b/xdelta3/xdelta3-regtest.py
@@ -21,7 +21,7 @@
21# TODO: This is really part test, part performance evaluation suite, and 21# TODO: This is really part test, part performance evaluation suite, and
22# really incomplete. 22# really incomplete.
23 23
24import os, sys, math, re, time, types, array 24import os, sys, math, re, time, types, array, random
25import xdelta3 25import xdelta3
26 26
27HIST_SIZE = 10 # the number of buckets 27HIST_SIZE = 10 # the number of buckets
@@ -31,7 +31,7 @@ TIME_TOO_SHORT = 0.050
31 31
32MIN_REPS = 1 32MIN_REPS = 1
33MAX_REPS = 1 33MAX_REPS = 1
34SKIP_TRIALS = 1 34SKIP_TRIALS = 2
35MIN_TRIALS = 3 35MIN_TRIALS = 3
36MAX_TRIALS = 15 36MAX_TRIALS = 15
37 37
@@ -216,6 +216,15 @@ class RcsFile:
216 os.remove(self.Verf(self.totrev-1)) 216 os.remove(self.Verf(self.totrev-1))
217 os.remove(self.Verf(self.totrev-2)) 217 os.remove(self.Verf(self.totrev-2))
218 return ntrials 218 return ntrials
219
220 def AppendVersion(self, f, n):
221 self.Checkout(n)
222 rf = open(self.Verf(n), "r")
223 data = rf.read()
224 f.write(data)
225 rf.close()
226 return len(data)
227
219# 228#
220# This class recursively scans a directory for rcsfiles 229# This class recursively scans a directory for rcsfiles
221class RcsFinder: 230class RcsFinder:
@@ -428,6 +437,7 @@ def RunCommandIO(args,infn,outfn):
428 437
429def RunXdelta3(args): 438def RunXdelta3(args):
430 try: 439 try:
440 #print 'RUN', args
431 xdelta3.main(args) 441 xdelta3.main(args)
432 except Exception, e: 442 except Exception, e:
433 raise CommandError(args, "xdelta3.main exception") 443 raise CommandError(args, "xdelta3.main exception")
@@ -453,6 +463,7 @@ class Xdelta3Pair:
453 self.type = 'xdelta3' 463 self.type = 'xdelta3'
454 self.decode_args = '-dqf' 464 self.decode_args = '-dqf'
455 self.encode_args = '-eqf' 465 self.encode_args = '-eqf'
466 self.extra = []
456 self.presrc = '-s' 467 self.presrc = '-s'
457 self.canrep = 1 468 self.canrep = 1
458 469
@@ -465,8 +476,9 @@ class Xdelta3Pair:
465 476
466 def Run(self,trial,reps): 477 def Run(self,trial,reps):
467 RunXdelta3(['-P', 478 RunXdelta3(['-P',
468 '%d' % reps, 479 '%d' % reps] +
469 self.encode_args, 480 self.extra +
481 [self.encode_args,
470 self.presrc, 482 self.presrc,
471 self.old, 483 self.old,
472 self.new, 484 self.new,
@@ -498,7 +510,7 @@ def Test():
498 len(rcsf.skipped)) 510 len(rcsf.skipped))
499 print StatList([x.rcssize for x in rcsf.rcsfiles], "rcssize", 1).str 511 print StatList([x.rcssize for x in rcsf.rcsfiles], "rcssize", 1).str
500 print StatList([x.totrev for x in rcsf.rcsfiles], "totrev", 1).str 512 print StatList([x.totrev for x in rcsf.rcsfiles], "totrev", 1).str
501 pairs = rcsf.PairsByDate(Xdelta3Pair()) 513 return rcsf
502 514
503def Decimals(max): 515def Decimals(max):
504 l = [0] 516 l = [0]
@@ -547,6 +559,52 @@ def ReportSpeed(L,tr,desc):
547 print '%s 0-run length %u: dsize %u: time %.3f ms: encode %.0f B/sec: in %ux%u trials' % \ 559 print '%s 0-run length %u: dsize %u: time %.3f ms: encode %.0f B/sec: in %ux%u trials' % \
548 (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)
549 561
562def BigFileRuns(rcsf):
563 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
584 while 1:
585
586 extras = [
587 ['-1'],
588 ['-C', '32,32,4,2,2,1,0,0,64,0'],
589 ['-9'],
590 ['-C', '64,64,4,128,16,0,1,8,128,0'],
591 ]
592
593 for extra in extras:
594 runner = Xdelta3Pair()
595 runner.extra = extra
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
550def RunSpeed(): 608def RunSpeed():
551 for L in Decimals(MAX_RUN): 609 for L in Decimals(MAX_RUN):
552 SetFileSize(RUNFILE, L) 610 SetFileSize(RUNFILE, L)
@@ -558,9 +616,11 @@ def RunSpeed():
558if __name__ == "__main__": 616if __name__ == "__main__":
559 try: 617 try:
560 os.mkdir(TMPDIR) 618 os.mkdir(TMPDIR)
561 Test() 619 rcsf = Test()
562 RunSpeed() 620 #rcsf.PairsByDate(Xdelta3Pair())
621 #RunSpeed()
622 BigFileRuns(rcsf)
563 except CommandError: 623 except CommandError:
564 pass 624 pass
565 else: 625
566 RunCommand(['rm', '-rf', TMPDIR]) 626 RunCommand(['rm', '-rf', TMPDIR])