@@ -122,37 +122,36 @@ def run(self, cwd, args):
122122 return ret_code , out .data
123123
124124
125- class AbstractPythonNoWarmupVm (AbstractPythonVm ):
125+ class AbstractPythonIterationsControlVm (AbstractPythonVm ):
126126 __metaclass__ = ABCMeta
127127
128- def __init__ (self , config_name , options = None , no_warmup = False ):
129- super (AbstractPythonNoWarmupVm , self ).__init__ (config_name , options )
130- self ._no_warmup = no_warmup
128+ def __init__ (self , config_name , options = None , iterations = None ):
129+ super (AbstractPythonIterationsControlVm , self ).__init__ (config_name , options )
130+ self ._iterations = iterations
131131
132- @staticmethod
133- def remove_warmup_runs (args ):
132+ def _override_iterations_args (self , args ):
134133 _args = []
135134 i = 0
136135 while i < len (args ):
137136 arg = args [i ]
138137 _args .append (arg )
139138 if arg == '-i' :
140- _args .append ('0' )
139+ _args .append (str ( self . _iterations ) )
141140 i += 1
142141 i += 1
143142 return _args
144143
145144 def run (self , cwd , args ):
146- if self ._no_warmup :
147- args = AbstractPythonNoWarmupVm . remove_warmup_runs (args )
148- return super (AbstractPythonNoWarmupVm , self ).run (cwd , args )
145+ if isinstance ( self ._iterations , ( int , long )) :
146+ args = self . _override_iterations_args (args )
147+ return super (AbstractPythonIterationsControlVm , self ).run (cwd , args )
149148
150149
151- class CPythonVm (AbstractPythonNoWarmupVm ):
150+ class CPythonVm (AbstractPythonIterationsControlVm ):
152151 PYTHON_INTERPRETER = "python3"
153152
154- def __init__ (self , config_name , options = None , virtualenv = None , no_warmup = False ):
155- super (CPythonVm , self ).__init__ (config_name , options = options , no_warmup = no_warmup )
153+ def __init__ (self , config_name , options = None , virtualenv = None , iterations = False ):
154+ super (CPythonVm , self ).__init__ (config_name , options = options , iterations = iterations )
156155 self ._virtualenv = virtualenv
157156
158157 @property
@@ -165,11 +164,11 @@ def name(self):
165164 return VM_NAME_CPYTHON
166165
167166
168- class PyPyVm (AbstractPythonNoWarmupVm ):
167+ class PyPyVm (AbstractPythonIterationsControlVm ):
169168 PYPY_INTERPRETER = "pypy3"
170169
171- def __init__ (self , config_name , options = None , no_warmup = False ):
172- super (PyPyVm , self ).__init__ (config_name , options = options , no_warmup = no_warmup )
170+ def __init__ (self , config_name , options = None , iterations = False ):
171+ super (PyPyVm , self ).__init__ (config_name , options = options , iterations = iterations )
173172
174173 @property
175174 def interpreter (self ):
0 commit comments