def open_in_browser(self, session, output_filename=None):
if output_filename is None:<EOL><INDENT>output_file = tempfile.NamedTemporaryFile(suffix='<STR_LIT>', delete=False)<EOL>output_filename = output_file.name<EOL>with codecs.getwriter('<STR_LIT:utf-8>')(output_file) as f:<EOL><INDENT>f.write(self.render(session))<EOL><DEDENT><DEDENT>else:<EOL><INDENT>with codecs.open(output_filename, '<STR_LIT:w>', '<STR_LIT:utf-8>') as f:<EOL><INDENT>f.write(self.render(session))<EOL><DEDENT><DEDENT>from pyinstrument.vendor.six.moves import urllib<EOL>url = urllib.parse.urlunparse(('<STR_LIT:file>', '<STR_LIT>', output_filename, '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'))<EOL>webbrowser.open(url)<EOL>return output_filename<EOL>
Open the rendered HTML in a webbrowser.

If output_filename=None (the default), a tempfile is used.

The filename of the HTML file is returned.