@@ -122,37 +122,36 @@ def run(self, cwd, args):
122
122
return ret_code , out .data
123
123
124
124
125
- class AbstractPythonNoWarmupVm (AbstractPythonVm ):
125
+ class AbstractPythonIterationsControlVm (AbstractPythonVm ):
126
126
__metaclass__ = ABCMeta
127
127
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
131
131
132
- @staticmethod
133
- def remove_warmup_runs (args ):
132
+ def _override_iterations_args (self , args ):
134
133
_args = []
135
134
i = 0
136
135
while i < len (args ):
137
136
arg = args [i ]
138
137
_args .append (arg )
139
138
if arg == '-i' :
140
- _args .append ('0' )
139
+ _args .append (str ( self . _iterations ) )
141
140
i += 1
142
141
i += 1
143
142
return _args
144
143
145
144
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 )
149
148
150
149
151
- class CPythonVm (AbstractPythonNoWarmupVm ):
150
+ class CPythonVm (AbstractPythonIterationsControlVm ):
152
151
PYTHON_INTERPRETER = "python3"
153
152
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 )
156
155
self ._virtualenv = virtualenv
157
156
158
157
@property
@@ -165,11 +164,11 @@ def name(self):
165
164
return VM_NAME_CPYTHON
166
165
167
166
168
- class PyPyVm (AbstractPythonNoWarmupVm ):
167
+ class PyPyVm (AbstractPythonIterationsControlVm ):
169
168
PYPY_INTERPRETER = "pypy3"
170
169
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 )
173
172
174
173
@property
175
174
def interpreter (self ):
0 commit comments