<s> import os <EOL> import sys <EOL> import time <EOL> import pstats <EOL> import logging <EOL> import cProfile <EOL> import subprocess <EOL> from subprocess import Popen <EOL> log = logging . getLogger ( __name__ ) <EOL> def show_file ( file_path ) : <EOL> def _view_linux2 ( ) : <EOL> Popen ( '<STR_LIT>' + file_path , shell = True ) <EOL> def _view_win32 ( ) : <EOL> os . startfile ( os . path . normpath ( file_path ) ) <EOL> def _view_darwin ( ) : <EOL> Popen ( '<STR_LIT>' + file_path , shell = True ) <EOL> locals ( ) . get ( '<STR_LIT>' + sys . platform ) ( ) <EOL> def run_profile ( test_cmd , var_env , save_dir ) : <EOL> """<STR_LIT>""" <EOL> dat_file = os . path . join ( save_dir , '<STR_LIT>' ) <EOL> png_file = os . path . join ( save_dir , '<STR_LIT>' ) <EOL> if not os . path . exists ( save_dir ) : <EOL> os . mkdir ( save_dir ) <EOL> cProfile . runctx ( test_cmd , var_env , var_env , dat_file ) <EOL> subprocess . Popen ( '<STR_LIT>' , cwd = save_dir , shell = True ) <EOL> time . sleep ( <NUM_LIT:1> ) <EOL> show_file ( png_file ) <EOL> st = pstats . Stats ( ) <EOL> st . load_stats ( dat_file ) <EOL> st . strip_dirs ( ) . sort_stats ( - <NUM_LIT:1> ) . print_stats ( ) </s>
