Brython if : && vs ,

Benchmark created on


Setup

frame = {
	line: 0
}
function set_lineno(frame, line) {
	frame.line = line
	return true;
}
function set_linenu(frame, line) {
	frame.line = line
	return true;
}

Test runner

Ready to run.

Testing in
TestOps/sec
Brython
let count = 0;
for( let i = 0; i < 100000; ++i)
	if( set_lineno(frame, i) && (i%3) )
	      ++count
	
	console.log(frame.line, count)
ready
Using comma
let count = 0;
for( let i = 0; i < 100000; ++i)
	if( set_lineno(frame, i), (i%3) )
	      ++count
	
	console.log(frame.line, count)
ready
comma no returns
let count = 0;
for( let i = 0; i < 100000; ++i)
	if( set_linenu(frame, i), (i%3) )
	      ++count
	
	console.log(frame.line, count)
ready

Revisions

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