viff

changeset 922:71428d0f7888

Updated benchmark.py to use make_runtime_class.
author Sigurd Meldgaard <stm@daimi.au.dk>
date Wed, 17 Sep 2008 14:39:55 +0200
parents dab7f77c5fc8
children 560a15b4b360
files apps/benchmark.py
diffstat 1 files changed, 15 insertions(+), 18 deletions(-) [+]
line diff
     1.1 --- a/apps/benchmark.py	Mon Sep 08 18:31:14 2008 +0200
     1.2 +++ b/apps/benchmark.py	Wed Sep 17 14:39:55 2008 +0200
     1.3 @@ -62,7 +62,8 @@
     1.4  from twisted.internet import reactor
     1.5  
     1.6  from viff.field import GF, GF256
     1.7 -from viff.runtime import Runtime, create_runtime, gather_shares
     1.8 +from viff.runtime import Runtime, create_runtime, gather_shares, \
     1.9 +    make_runtime_class
    1.10  from viff.active import BasicActiveRuntime, \
    1.11      TriplesHyperinvertibleMatricesMixin, TriplesPRSSMixin
    1.12  from viff.comparison import ComparisonToft05Mixin, ComparisonToft07Mixin
    1.13 @@ -243,41 +244,37 @@
    1.14              record_stop(None, "sequential test")
    1.15              self.finished(None)
    1.16  
    1.17 +mixins = []
    1.18  if options.twoplayer:
    1.19      # Then there is just one possible runtime:
    1.20      operation = operator.mul
    1.21 -    bases = [PaillierRuntime]
    1.22 +    base_runtime_class = PaillierRuntime
    1.23  else:
    1.24      # There are several options for a multiplayer runtime:
    1.25      if options.active:
    1.26 -        bases = [BasicActiveRuntime]
    1.27 +        base_runtime_class = BasicActiveRuntime
    1.28          if options.prss:
    1.29 -            bases.append(TriplesPRSSMixin)
    1.30 +            mixins.append(TriplesPRSSMixin)
    1.31          else:
    1.32 -            bases.append(TriplesHyperinvertibleMatricesMixin)
    1.33 +            mixins.append(TriplesHyperinvertibleMatricesMixin)
    1.34      else:
    1.35 -        bases = [Runtime]
    1.36 +        base_runtime_class = Runtime
    1.37  
    1.38      if options.operation == "mul":
    1.39          operation = operator.mul
    1.40      elif options.operation == "compToft05":
    1.41          operation = operator.ge
    1.42 -        bases.append(ComparisonToft05Mixin)
    1.43 +        mixins.append(ComparisonToft05Mixin)
    1.44      elif options.operation == "compToft07":
    1.45          operation = operator.ge
    1.46 -        bases.append(ComparisonToft07Mixin)
    1.47 +        mixins.append(ComparisonToft07Mixin)
    1.48  
    1.49 -print "Constructing runtime from:"
    1.50 -for base in bases:
    1.51 -    print "- %s" % base
    1.52 +print "Using the base runtime: %s." % base_runtime_class
    1.53 +print "With the following mixins:"
    1.54 +for mixin in mixins:
    1.55 +    print "- %s" % mixin
    1.56  
    1.57 -
    1.58 -# We must include at least one new-style class in bases. We include it
    1.59 -# last to avoid overriding __init__ from the other base classes.
    1.60 -bases.append(object)
    1.61 -
    1.62 -# Dynamically created class based on the choices above:
    1.63 -runtime_class = type("BenchmarkRuntime", tuple(bases), {})
    1.64 +runtime_class = make_runtime_class(base_runtime_class, mixins)
    1.65  
    1.66  if options.parallel:
    1.67      benchmark = ParallelBenchmark