def run_exec_time(deno_exe, build_dir): hyperfine_exe = third_party.get_prebuilt_tool_path("hyperfine") benchmark_file = os.path.join(build_dir, "hyperfine_results.json") def benchmark_command(deno_exe, args, return_code): # Bash test which asserts the return code value of the previous command # $? contains the return code of the previous command return_code_test = "; test $? -eq {}".format( return_code) if return_code is not None else "" return "{} {}{}".format(deno_exe, " ".join(args), return_code_test) run([hyperfine_exe, "--export-json", benchmark_file, "--warmup", "3"] + [ benchmark_command(deno_exe, args, return_code) for (_, args, return_code) in exec_time_benchmarks ]) hyperfine_results = read_json(benchmark_file) results = {} for [[name, _, _], data] in zip(exec_time_benchmarks, hyperfine_results["results"]): results[name] = { "mean": data["mean"], "stddev": data["stddev"], "user": data["user"], "system": data["system"], "min": data["min"], "max": data["max"] } return results
def generate_gn_args(mode): out = [] if mode == "release": out += ["is_official_build=true", "symbol_level=0"] elif mode == "debug": out += ["is_debug=true"] else: print "Bad mode {}. Use 'release' or 'debug' (default)" % mode sys.exit(1) if "DENO_BUILD_ARGS" in os.environ: out += os.environ["DENO_BUILD_ARGS"].split() cacher = find_executable("sccache") if not os.path.exists(cacher): cacher = third_party.get_prebuilt_tool_path("sccache") # Check if ccache or sccache are in the path, and if so we set cc_wrapper. cc_wrapper = cacher if cc_wrapper: # The gn toolchain does not shell escape cc_wrapper, so do it here. out += ['cc_wrapper=%s' % gn_string(shell_quote(cc_wrapper))] if os.name == "nt": # Disable treat_warnings_as_errors until this sccache bug is fixed: # https://github.com/mozilla/sccache/issues/264 out += ["treat_warnings_as_errors=false"] return out
def run(server_cmd, port, merge_env=None, origin_cmd=None): # Run deno echo server in the background. if merge_env is None: env = None else: env = os.environ.copy() for key, value in merge_env.iteritems(): env[key] = value # Wait for port 4544 to become available. # TODO Need to use SO_REUSEPORT with tokio::net::TcpListener. time.sleep(5) origin = None if origin_cmd is not None: origin = subprocess.Popen(origin_cmd, env=env) print server_cmd server = subprocess.Popen(server_cmd, env=env) time.sleep(5) # wait for server to wake up. TODO racy. try: wrk = third_party.get_prebuilt_tool_path("wrk") assert os.path.exists(wrk) cmd = "%s -d %s --latency http://127.0.0.1:%s/" % (wrk, DURATION, port) print cmd output = subprocess.check_output(cmd, shell=True) stats = util.parse_wrk_output(output) print output return stats finally: server_retcode = server.poll() if server_retcode is not None and server_retcode != 0: print "server ended with error" sys.exit(1) server.kill() if origin is not None: origin.kill()
def run_exec_time(deno_exe, build_dir): hyperfine_exe = third_party.get_prebuilt_tool_path("hyperfine") benchmark_file = os.path.join(build_dir, "hyperfine_results.json") run([ hyperfine_exe, "--ignore-failure", "--export-json", benchmark_file, "--warmup", "3" ] + [ deno_exe + " " + " ".join(args) for [_, args] in exec_time_benchmarks ]) hyperfine_results = read_json(benchmark_file) results = {} for [[name, _], data] in zip(exec_time_benchmarks, hyperfine_results["results"]): results[name] = { "mean": data["mean"], "stddev": data["stddev"], "user": data["user"], "system": data["system"], "min": data["min"], "max": data["max"] } return results
def dlint(): executable_path = get_prebuilt_tool_path("dlint") # Find all *directories* in the main repo that contain .ts/.js files. source_files = get_sources(root_path, [ "*.js", "*.ts", ":!:cli/tests/swc_syntax_error.ts", ":!:cli/tests/038_checkjs.js", ":!:cli/tests/error_008_checkjs.js", ":!:std/**/testdata/*", ":!:std/**/node_modules/*", ":!:cli/bench/node*.js", ":!:cli/compilers/wasm_wrap.js", ":!:cli/dts/**", ":!:cli/tests/encoding/**", ":!:cli/tests/error_syntax.js", ":!:cli/tests/lint/**", ":!:cli/tests/tsc/**", ":!:cli/tsc/*typescript.js", ]) if source_files: max_command_len = 30000 pre_command = [executable_path, "run"] chunks = [[]] cmd_len = len(" ".join(pre_command)) for f in source_files: if cmd_len + len(f) > max_command_len: chunks.append([f]) cmd_len = len(" ".join(pre_command)) else: chunks[-1].append(f) cmd_len = cmd_len + len(f) + 1 for c in chunks: print_command("dlint", c) run(pre_command + c, shell=False, quiet=True)
def dprint(): executable_path = get_prebuilt_tool_path("dprint") command = [executable_path, "fmt"] run(command, shell=False, quiet=True)