Skip to content

Commit

Permalink
chore: Make rust-analyzer faster (#2962)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdy1 authored Dec 3, 2021
1 parent c346f12 commit 02322aa
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,8 @@
"eslint.enable": false,
"cSpell.allowCompoundWords": true,
"cSpell.caseSensitive": true,
"rust-analyzer.checkOnSave.features": [
// We use this to make IDE faster
"rust-analyzer"
]
}
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion crates/testing_macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ edition = "2018"
license = "Apache-2.0"
name = "testing_macros"
repository = "https://github.com/swc-project/swc.git"
version = "0.2.4"
version = "0.2.5"

[features]
# Skip generating fixtures so the editor becomes faster again
rust-analyzer = []

[lib]
proc-macro = true
Expand Down
10 changes: 10 additions & 0 deletions crates/testing_macros/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use pmutil::q;
use proc_macro::TokenStream;
use quote::ToTokens;
use syn::ItemFn;
Expand Down Expand Up @@ -54,6 +55,15 @@ mod fixture;
#[proc_macro_attribute]
pub fn fixture(attr: TokenStream, item: TokenStream) -> TokenStream {
let item: ItemFn = syn::parse(item).expect("failed to parse input as a function item");

if cfg!(feature = "rust-analyzer") {
return q!(Vars { item }, {
#[allow(unused)]
item
})
.into();
}

let config: self::fixture::Config =
syn::parse(attr).expect("failed to parse input passed to #[fixture]");

Expand Down

1 comment on commit 02322aa

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Benchmark

Benchmark suite Current: 02322aa Previous: fd8541e Ratio
base_tr_fixer 25748 ns/iter (± 452) 22240 ns/iter (± 260) 1.16
base_tr_resolver_and_hygiene 145036 ns/iter (± 26902) 128499 ns/iter (± 25311) 1.13
codegen_es2015 61124 ns/iter (± 414) 52768 ns/iter (± 647) 1.16
codegen_es2016 60725 ns/iter (± 436) 52670 ns/iter (± 522) 1.15
codegen_es2017 61042 ns/iter (± 819) 52365 ns/iter (± 492) 1.17
codegen_es2018 60796 ns/iter (± 353) 52256 ns/iter (± 495) 1.16
codegen_es2019 60687 ns/iter (± 1146) 52771 ns/iter (± 385) 1.15
codegen_es2020 60648 ns/iter (± 506) 52517 ns/iter (± 555) 1.15
codegen_es3 60442 ns/iter (± 428) 52348 ns/iter (± 458) 1.15
codegen_es5 61042 ns/iter (± 656) 52859 ns/iter (± 686) 1.15
full_es2015 201875396 ns/iter (± 8283034) 184217362 ns/iter (± 7673244) 1.10
full_es2016 160980433 ns/iter (± 7594427) 146624884 ns/iter (± 10542526) 1.10
full_es2017 166291711 ns/iter (± 9453762) 160332385 ns/iter (± 9352224) 1.04
full_es2018 164029011 ns/iter (± 11062594) 160615063 ns/iter (± 14351324) 1.02
full_es2019 162362399 ns/iter (± 10497079) 157271349 ns/iter (± 8966348) 1.03
full_es2020 161996612 ns/iter (± 7723926) 156564744 ns/iter (± 10003281) 1.03
full_es3 228806312 ns/iter (± 18809397) 225482878 ns/iter (± 11824709) 1.01
full_es5 213535213 ns/iter (± 10968807) 204995853 ns/iter (± 9341339) 1.04
parser 772690 ns/iter (± 20363) 682026 ns/iter (± 22471) 1.13
ser_ast_node 180 ns/iter (± 4) 152 ns/iter (± 2) 1.18
ser_serde 181 ns/iter (± 2) 152 ns/iter (± 1) 1.19
emit_colors 15904537 ns/iter (± 20739340) 17313519 ns/iter (± 22867348) 0.92
emit_large 108215122 ns/iter (± 165448618) 101344251 ns/iter (± 156215603) 1.07
base_clone 2831493 ns/iter (± 97367) 2612742 ns/iter (± 507742) 1.08
fold_span 4607459 ns/iter (± 38620) 4456273 ns/iter (± 1045201) 1.03
fold_span_panic 4793731 ns/iter (± 53499) 4705815 ns/iter (± 999285) 1.02
visit_mut_span 3408491 ns/iter (± 32792) 3078110 ns/iter (± 279457) 1.11
visit_mut_span_panic 3473445 ns/iter (± 34145) 3442313 ns/iter (± 946866) 1.01
ast_clone 20535 ns/iter (± 231) 17809 ns/iter (± 210) 1.15
ast_clone_to_stable 59281 ns/iter (± 453) 51976 ns/iter (± 542) 1.14
ast_clone_to_stable_then_to_unstable 110210 ns/iter (± 457) 95709 ns/iter (± 597) 1.15
json_deserialize 2260906 ns/iter (± 4702) 1889414 ns/iter (± 5811) 1.20
json_serialize 101063 ns/iter (± 428) 85430 ns/iter (± 610) 1.18
boxing_boxed 148 ns/iter (± 0) 126 ns/iter (± 0) 1.17
boxing_boxed_clone 81 ns/iter (± 0) 67 ns/iter (± 0) 1.21
boxing_unboxed 132 ns/iter (± 0) 112 ns/iter (± 0) 1.18
boxing_unboxed_clone 74 ns/iter (± 0) 71 ns/iter (± 0) 1.04
time_10 403 ns/iter (± 4) 329 ns/iter (± 1) 1.22
time_15 889 ns/iter (± 11) 698 ns/iter (± 6) 1.27
time_20 1412 ns/iter (± 8) 1317 ns/iter (± 5) 1.07
time_40 4818 ns/iter (± 31) 6598 ns/iter (± 17) 0.73
time_5 128 ns/iter (± 1) 107 ns/iter (± 1) 1.20
time_60 10198 ns/iter (± 51) 14884 ns/iter (± 663) 0.69

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.