diff options
author | Kitson Kelly <me@kitsonkelly.com> | 2020-10-01 20:32:05 +1000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-10-01 20:32:05 +1000 |
commit | ef5ae4547a4eb0a2fc2309a9dac934275b86ae82 (patch) | |
tree | 91f7d928e75ae8a5afce5b8f8188279f44e66561 | |
parent | da29ccece5e357b893ce9a5cf145fd6e939c1fb5 (diff) |
chore: ensure cache is 'valid' during benchmarks (#7770)
-rw-r--r-- | cli/bench/main.rs | 17 | ||||
-rw-r--r-- | cli/tsc_config.rs | 3 |
2 files changed, 11 insertions, 9 deletions
diff --git a/cli/bench/main.rs b/cli/bench/main.rs index cf640d1f7..aca6163d9 100644 --- a/cli/bench/main.rs +++ b/cli/bench/main.rs @@ -24,13 +24,9 @@ fn write_json(filename: &str, value: &Value) -> Result<()> { /// The list of the tuples of the benchmark name, arguments and return code const EXEC_TIME_BENCHMARKS: &[(&str, &[&str], Option<i32>)] = &[ - ("hello", &["run", "cli/tests/002_hello.ts"], None), - ( - "relative_import", - &["run", "cli/tests/003_relative_import.ts"], - None, - ), - ("error_001", &["run", "cli/tests/error_001.ts"], Some(1)), + // we need to run the cold_* benchmarks before the _warm_ ones as they ensure + // the cache is properly populated, instead of other tests possibly + // invalidating that cache. ( "cold_hello", &["run", "--reload", "cli/tests/002_hello.ts"], @@ -41,6 +37,13 @@ const EXEC_TIME_BENCHMARKS: &[(&str, &[&str], Option<i32>)] = &[ &["run", "--reload", "cli/tests/003_relative_import.ts"], None, ), + ("hello", &["run", "cli/tests/002_hello.ts"], None), + ( + "relative_import", + &["run", "cli/tests/003_relative_import.ts"], + None, + ), + ("error_001", &["run", "cli/tests/error_001.ts"], Some(1)), ( "no_check_hello", &["run", "--reload", "--no-check", "cli/tests/002_hello.ts"], diff --git a/cli/tsc_config.rs b/cli/tsc_config.rs index cf846cce7..736fb3557 100644 --- a/cli/tsc_config.rs +++ b/cli/tsc_config.rs @@ -237,8 +237,7 @@ impl TsConfig { ), ) })?; - let config_bytes = std::fs::read(config_path.clone())?; - let config_text = std::str::from_utf8(&config_bytes)?; + let config_text = std::fs::read_to_string(config_path.clone())?; let (value, maybe_ignored_options) = parse_config(&config_text, &config_path)?; json_merge(&mut self.0, &value); |