Real Brython (v3)

Revision 3 of this benchmark created on


Preparation HTML

<script src="https://raw.githack.com/brython-dev/brython/master/www/src/brython.js"
			crossorigin="anonymous" defer>
</script>

Setup

window.indexDB = {}

__BRYTHON__.imported = { __main__: {}}

__BRYTHON__.empty_dict = {}
__BRYTHON__.builtins = {
	None: null,
    globals: {},
    range: function* foo(a,b,c=1) {
	for(let i = a; i < b; i+=c)
		yield i;
	}

}

Test runner

Ready to run.

Testing in
TestOps/sec
Brython (with traces)
// Javascript code generated from ast
function foo() {
	
	var $B = __BRYTHON__,
    _b_ = $B.builtins,
    locals___main__ = $B.imported["__main__"],
    locals = locals___main__,
    frame = ["__main__", locals, "__main__", locals]
frame.__file__ = '<string>'
locals.__name__ = '__main__'
locals.__doc__ = _b_.None
locals.__annotations__ = locals.__annotations__ || $B.empty_dict()
frame.$f_trace = $B.enter_frame(frame)
$B.set_lineno(frame, 1)

var _frames = $B.frames_stack.slice()
var stack_length = $B.frames_stack.length
try{
  $B.set_lineno(frame, 1)
  function f1394(){
    var locals___main___f,
        locals
    locals___main___f = locals = $B.args0(f1394, arguments)
    var frame = ["f", locals, "__main__", locals___main__, f1394]
    if(locals.$has_generators){
      frame.$has_generators = true
    }
    frame.__file__ = '<string>'
    frame.$lineno = 1
    frame.$f_trace = $B.enter_frame(frame)
    try{
      $B.js_this = this
      $B.set_lineno(frame, 2)
      var result = locals___main___f.x
      if(frame.$f_trace !== _b_.None){
        $B.trace_return(result)
      }
      $B.leave_frame()
      return result
    }catch(err){
      $B.set_exc(err, frame)
      if((! err.$in_trace_func) && frame.$f_trace !== _b_.None){
        frame.$f_trace = $B.trace_exception()
      }
      $B.leave_frame();throw err
    }
  }
  f1394.$is_func = true
  f1394.$infos = {
    __module__: "__main__",
    __name__: "f",
    __qualname__: "f",
    __defaults__: $B.fast_tuple([]),
    __globals__: _b_.globals(),
    __kwdefaults__: _b_.None,
    __doc__: _b_.None,
    __code__:{
      co_argcount: 1,
      co_filename: '<string>',
      co_firstlineno: 1,
      co_flags: 3,
      co_freevars: $B.fast_tuple([]),
      co_kwonlyargcount: 0,
      co_name: 'f',
      co_nlocals: 1,
      co_posonlyargcount: 0,
      co_qualname: 'f',
      co_varnames: $B.fast_tuple(['x'])
    },
    arg_names: ['x'],
    vararg: null,
    kwarg: null
  }
  $B.make_function_defaults(f1394)
  locals___main__.f = f1394
  locals___main__.f.__annotations__ = $B.empty_dict()
  
  frame.$lineno = 3
  var no_break_1395 = true,
      iterator_1395 = $B.$call(_b_.range, [9, 9, 23])(1000000)
  for(var next_1395 of $B.make_js_iterator(iterator_1395, frame, 3)){
    var v1396 = next_1395
    locals___main__.i = v1396
    $B.set_lineno(frame, 4);
    $B.$call(locals___main__.f, [4, 4, 8])(locals___main__.i)
  }
  $B.leave_frame({locals, value: _b_.None})
}catch(err){
  $B.set_exc(err, frame)
  if((! err.$in_trace_func) && frame.$f_trace !== _b_.None){
    frame.$f_trace = $B.trace_exception()
  }
  $B.leave_frame({locals, value: _b_.None})
  throw err
}

}

setTimeout(foo, 1000)

ready
Without traces
// Javascript code generated from ast
function foo() {

var $B = __BRYTHON__,
    _b_ = $B.builtins,
    locals___main__ = $B.imported["__main__"],
    locals = locals___main__,
    frame = ["__main__", locals, "__main__", locals]
frame.__file__ = '<string>'
locals.__name__ = '__main__'
locals.__doc__ = _b_.None
locals.__annotations__ = locals.__annotations__ || $B.empty_dict()
frame.$f_trace = $B.enter_frame(frame)
$B.set_lineno(frame, 1)

var _frames = $B.frames_stack.slice()
var stack_length = $B.frames_stack.length
try{
  $B.set_lineno(frame, 1)
  function f1388(){
    var locals___main___f,
        locals
    locals___main___f = locals = $B.args0(f1388, arguments)
    var frame = ["f", locals, "__main__", locals___main__, f1388]
    if(locals.$has_generators){
      frame.$has_generators = true
    }
    frame.__file__ = '<string>'
    frame.$lineno = 1
    frame.$f_trace = $B.enter_frame(frame)
    try{
      $B.js_this = this
      $B.set_lineno(frame, 2)
      var result = locals___main___f.x
      $B.leave_frame()
      return result
    }catch(err){
      $B.set_exc(err, frame)
      $B.leave_frame();throw err
    }
  }
  f1388.$is_func = true
  f1388.$infos = {
    __module__: "__main__",
    __name__: "f",
    __qualname__: "f",
    __defaults__: $B.fast_tuple([]),
    __globals__: _b_.globals(),
    __kwdefaults__: _b_.None,
    __doc__: _b_.None,
    __code__:{
      co_argcount: 1,
      co_filename: '<string>',
      co_firstlineno: 1,
      co_flags: 3,
      co_freevars: $B.fast_tuple([]),
      co_kwonlyargcount: 0,
      co_name: 'f',
      co_nlocals: 1,
      co_posonlyargcount: 0,
      co_qualname: 'f',
      co_varnames: $B.fast_tuple(['x'])
    },
    arg_names: ['x'],
    vararg: null,
    kwarg: null
  }
  $B.make_function_defaults(f1388)
  locals___main__.f = f1388
  locals___main__.f.__annotations__ = $B.empty_dict()
  
  frame.$lineno = 3
  var no_break_1389 = true,
      iterator_1389 = $B.$call(_b_.range, [9, 9, 23])(1000000)
  for(var next_1389 of $B.make_js_iterator(iterator_1389, frame, 3)){
    var v1390 = next_1389
    locals___main__.i = v1390
    $B.set_lineno(frame, 4);
    $B.$call(locals___main__.f, [4, 4, 8])(locals___main__.i)
  }
  $B.leave_frame({locals, value: _b_.None})
}catch(err){
  $B.set_exc(err, frame)
  $B.leave_frame({locals, value: _b_.None})
  throw err
}

}

setTimeout(foo, 1000)
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.