difftreelog
perf std ast codegen
in: master
5 files changed
Cargo.lockdiffbeforeafterboth40 packageslockfile v1
Might be heavy and slow!
annotate-snippets
0.8.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd78ea013094e5ea606b1c05fe35f1dd7ea1eb1ea259908d040b25bd5ec677ee5used byautocfg
1.0.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9dused bybincode
1.3.1crates.io↘ 2↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896ddepends onbitflags
1.2.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693used bybyteorder
1.3.4crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472deused bycc
1.0.54crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311used byclap
3.0.0-beta.1crates.io↘ 8↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum860643c53f980f0d38a5e25dfab6c3c93b2cb3aa1fe192643d17a293c6c41936depends onused byclap_derive
3.0.0-beta.1crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumfb51c9e75b94452505acd21d929323f5a5c6c4735a852adbd39ef5fb1b014f30used byclosure
0.3.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd6173fd61b610d15a7566dd7b7620775627441c4ab9dac8906e17cb93a24b782used byfs_extra
1.1.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674used byheck
0.3.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205depends onused byindexmap
1.4.0crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afedepends onjemalloc-sys
0.3.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45depends onused byjemallocator
0.3.2crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69depends onused byjrsonnet
0.1.0workspace↘ 5↖ 0jsonnet-evaluator
0.1.0workspace↘ 7↖ 1jsonnet-parser
0.1.0workspace↘ 5↖ 2jsonnet-stdlib
0.1.0workspace↘ 0↖ 2lazy_static
1.4.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646used bylibc
0.2.71crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49md5
0.7.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771used byos_str_bytes
2.3.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum06de47b848347d8c4c94219ad8ecd35eb90231704b067e67e6ae2e36ee023510used bypeg
0.6.2crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9075875c14bb21f25f11cad4b6ad2e4dd443b8fb83900b2fbdd6ebd744b82e97depends onused bypeg-macros
0.6.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc24c165fd39e995246140cc78df55c56c6733ba87e6658cb3e197b8856c62852used bypeg-runtime
0.6.2crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum0c1a2897e69d986c7986747ebad425cf03746ec5e3e09bb3b2600f91301ba864used byproc-macro-error
0.4.12crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7used byproc-macro-error-attr
0.4.12crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69deused byproc-macro2
1.0.18crates.io↘ 1↖ 8sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbeae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fadepends onquote
1.0.5crates.io↘ 1↖ 7sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum42934bc9c8ab0d3b273a16d8551c8f0fcff46be73276ca083ec2414c15c4ba5edepends onserde
1.0.114crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3depends onserde_derive
1.0.114crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8edepends onused bysyn
1.0.33crates.io↘ 3↖ 5sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cdsyn-mid
0.5.0crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338adepends onused bytextwrap
0.11.0crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060depends onused byunescape
0.1.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumccb97dac3243214f8d8507998906ca3e2e0b900bf9bf4870477f125b82e68f6eused byunicode-segmentation
1.6.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0used byunicode-width
0.1.7crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcaaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479unicode-xid
0.2.0crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097cused byvec_map
0.8.2crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191used byversion_check
0.9.2crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed
42 packageslockfile v1
Might be heavy and slow!
annotate-snippets
0.8.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd78ea013094e5ea606b1c05fe35f1dd7ea1eb1ea259908d040b25bd5ec677ee5used byautocfg
1.0.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf8aac770f1885fd7e387acedd76065302551364496e46b3dd00860b2f8359b9dused bybincode
1.3.1crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf30d3a39baa26f9651f17b375061f3233dde33424a8b72b0dbe93a68a0bc896ddepends onused bybitflags
1.2.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693used bybyteorder
1.3.4crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472deused bycc
1.0.54crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7bbb73db36c1246e9034e307d0fba23f9a2e251faa47ade70c1bd252220c8311used byclap
3.0.0-beta.1crates.io↘ 8↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum860643c53f980f0d38a5e25dfab6c3c93b2cb3aa1fe192643d17a293c6c41936depends onused byclap_derive
3.0.0-beta.1crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumfb51c9e75b94452505acd21d929323f5a5c6c4735a852adbd39ef5fb1b014f30used byclosure
0.3.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd6173fd61b610d15a7566dd7b7620775627441c4ab9dac8906e17cb93a24b782used byfs_extra
1.1.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5f2a4a2034423744d2cc7ca2068453168dcdb82c438419e639a26bd87839c674used byheck
0.3.1crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum20564e78d53d2bb135c343b3f47714a56af2061f1c928fdb541dc7b9fdd94205depends onused byindexmap
1.4.0crates.io↘ 1↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc398b2b113b55809ceb9ee3e753fcbac793f1956663f3c36549c1346015c2afedepends onjemalloc-sys
0.3.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum0d3b9f3f5c9b31aa0f5ed3260385ac205db665baa41d49bb8338008ae94ede45depends onused byjemallocator
0.3.2crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum43ae63fcfc45e99ab3d1b29a46782ad679e98436c3169d15a167a1108a724b69depends onused byjrsonnet
0.1.0workspace↘ 5↖ 0jsonnet-evaluator
0.1.0workspace↘ 8↖ 1jsonnet-parser
0.1.0workspace↘ 6↖ 2jsonnet-stdlib
0.1.0workspace↘ 0↖ 2lazy_static
1.4.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646used bylibc
0.2.71crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9457b06509d27052635f90d6466700c65095fdf75409b3fbdd903e988b886f49md5
0.7.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum490cc448043f947bae3cbee9c203358d62dbee0db12107a74be5c30ccfd09771used byos_str_bytes
2.3.1crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum06de47b848347d8c4c94219ad8ecd35eb90231704b067e67e6ae2e36ee023510used bypeg
0.6.2crates.io↘ 2↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum9075875c14bb21f25f11cad4b6ad2e4dd443b8fb83900b2fbdd6ebd744b82e97depends onused bypeg-macros
0.6.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumc24c165fd39e995246140cc78df55c56c6733ba87e6658cb3e197b8856c62852used bypeg-runtime
0.6.2crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum0c1a2897e69d986c7986747ebad425cf03746ec5e3e09bb3b2600f91301ba864used byproc-macro-error
0.4.12crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum18f33027081eba0a6d8aba6d1b1c3a3be58cbb12106341c2d5759fcd9b5277e7used byproc-macro-error-attr
0.4.12crates.io↘ 5↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum8a5b4b77fdb63c1eca72173d68d24501c54ab1269409f6b672c85deb18af69deused byproc-macro2
1.0.18crates.io↘ 1↖ 9sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumbeae6331a816b1f65d04c45b078fd8e6c93e8071771f41b8163255bbd8d7c8fadepends onquote
1.0.7crates.io↘ 1↖ 8sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumaa563d17ecb180e500da1cfd2b028310ac758de548efdd203e18f283af693f37depends onserde
1.0.114crates.io↘ 1↖ 3sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum5317f7588f0a5078ee60ef675ef96735a1442132dc645eb1d12c018620ed8cd3depends onserde_derive
1.0.114crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2a0be94b04690fbaed37cddffc5c134bf537c8e3329d53e982fe04c374978f8edepends onused bystructdump
0.1.2crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum2e16ec33a0342fdb67d13913b4ffae6527ebccfa04b5d7da174bdc7a31db29b8structdump-derive
0.1.2crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum06c337fdc077e02ccbfcc62af0090564a4af342975c3b7be09705efab90c1888depends onused bysyn
1.0.33crates.io↘ 3↖ 6sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume8d5d96e8cbb005d6959f119f773bfaebb5684296108fb32600c00cde305b2cdsyn-mid
0.5.0crates.io↘ 3↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum7be3539f6c128a931cf19dcee741c1af532c7fd387baa739c03dd2e96479338adepends onused bytextwrap
0.11.0crates.io↘ 1↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumd326610f408c7a4eb6f51c37c330e496b08506c9457c9d34287ecc38809fb060depends onused byunescape
0.1.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumccb97dac3243214f8d8507998906ca3e2e0b900bf9bf4870477f125b82e68f6eused byunicode-segmentation
1.6.0crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksume83e153d1053cbb5a118eeff7fd5be06ed99153f00dbcd8ae310c5fb2b22edc0used byunicode-width
0.1.7crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumcaaa9d531767d1ff2150b9332433f32a24622147e5ebb1f26409d5da67afd479unicode-xid
0.2.0crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksum826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097cused byvec_map
0.8.2crates.io↘ 0↖ 1sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumf1bddf1187be692e79c5ffeab891132dfb0f236ed36a43c7ed39f1165ee20191used byversion_check
0.9.2crates.io↘ 0↖ 2sourceregistry+https://github.com/rust-lang/crates.io-indexchecksumb5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed
crates/jsonnet-evaluator/Cargo.tomldiffbeforeafterboth--- a/crates/jsonnet-evaluator/Cargo.toml
+++ b/crates/jsonnet-evaluator/Cargo.toml
@@ -9,8 +9,10 @@
[features]
default = ["serialized-stdlib", "faster"]
# Serializes standard library AST instead of parsing them every run
-serialized-stdlib = ["serde", "bincode"]
-# Replace some standard library functions with faster implementations
+serialized-stdlib = ["serde", "bincode", "jsonnet-parser/deserialize"]
+# Same as above, but with generated code instead of serde. Reduces memory usage, but increases binary size and compilation time
+codegenerated-stdlib = []
+# Replace some standard library functions with faster implementations (I.e manifestJsonEx)
# Library works fine without this feature, but requires more memory and time for std function calls
faster = []
@@ -21,16 +23,12 @@
indexmap = "1.4.0"
md5 = "0.7.0"
-[dependencies.serde]
-version = "1.0.114"
-optional = true
+serde = { version = "1.0.114", optional = true }
+bincode = { version = "1.3.1", optional = true }
-[dependencies.bincode]
-version = "1.3.1"
-optional = true
-
[build-dependencies]
-jsonnet-parser = { path = "../jsonnet-parser" }
+jsonnet-parser = { path = "../jsonnet-parser", features = ["dump", "serialize", "deserialize"] }
jsonnet-stdlib = { path = "../jsonnet-stdlib" }
+structdump = "0.1.2"
serde = "1.0.114"
bincode = "1.3.1"
crates/jsonnet-evaluator/README.mddiffbeforeafterboth--- a/crates/jsonnet-evaluator/README.md
+++ b/crates/jsonnet-evaluator/README.md
@@ -2,6 +2,35 @@
Interpreter for parsed jsonnet tree
+## Standard library
+
+jsonnet stdlib is embedded into evaluator, but there is different modes for this:
+
+- `codegenerated-stdlib`
+ - generates source code for reproducing stdlib AST ([Example](https://gist.githubusercontent.com/CertainLach/7b3149df556f3406f5e9368aaa9f32ec/raw/0c80d8ab9aa7b9288c6219a2779cb2ab37287669/a.rs))
+ - fastest on interpretation, slowest on compilation (it takes more than 5 minutes to optimize them by llvm)
+- `serialized-stdlib`
+ - serializes standard library AST using serde
+ - slower than `codegenerated-stdlib` at runtime, but have no compilation speed penality
+- none
+ - leaves only stdlib source code in binary, processing them same way as user supplied data
+ - slowest (as it involves parsing of standard library source code)
+
+Because of `codegenerated-stdlib` compilation slowdown, `serialized-stdlib` is used by default
+
+### Benchmark
+
+Can also be run via `cargo bench`
+
+```md
+# codegenerated-stdlib
+test tests::bench_codegen ... bench: 401,696 ns/iter (+/- 38,521)
+# serialized-stdlib
+test tests::bench_serialize ... bench: 1,763,999 ns/iter (+/- 76,211)
+# none
+test tests::bench_parse ... bench: 7,206,164 ns/iter (+/- 1,067,418)
+```
+
## Intristics
Some functions from stdlib are implemented as intristics
crates/jsonnet-evaluator/build.rsdiffbeforeafterboth--- a/crates/jsonnet-evaluator/build.rs
+++ b/crates/jsonnet-evaluator/build.rs
@@ -10,6 +10,7 @@
path::{Path, PathBuf},
rc::Rc,
};
+use structdump::CodegenResult;
fn main() {
let parsed = parse(
@@ -46,10 +47,19 @@
} else {
parsed
};
+ {
+ let mut codegen = CodegenResult::default();
+ let code = codegen.codegen(&parsed);
- let out_dir = env::var("OUT_DIR").unwrap();
- let dest_path = Path::new(&out_dir).join("stdlib.bincode");
- let mut f = File::create(&dest_path).unwrap();
- f.write_all(&serialize(&parsed).expect("serialize"))
- .unwrap();
+ let out_dir = env::var("OUT_DIR").unwrap();
+ let dest_path = Path::new(&out_dir).join("stdlib.rs");
+ let mut f = File::create(&dest_path).unwrap();
+ f.write_all(&code.as_bytes()).unwrap();
+ }
+ {
+ let out_dir = env::var("OUT_DIR").unwrap();
+ let dest_path = Path::new(&out_dir).join("stdlib.bincode");
+ let mut f = File::create(&dest_path).unwrap();
+ f.write_all(&serialize(&parsed).unwrap()).unwrap();
+ }
}
crates/jsonnet-evaluator/src/lib.rsdiffbeforeafterboth--- a/crates/jsonnet-evaluator/src/lib.rs
+++ b/crates/jsonnet-evaluator/src/lib.rs
@@ -1,7 +1,11 @@
#![feature(box_syntax, box_patterns)]
#![feature(type_alias_impl_trait)]
#![feature(debug_non_exhaustive)]
+#![feature(test)]
#![allow(macro_expanded_macro_exports_accessed_by_absolute_paths)]
+
+extern crate test;
+
mod ctx;
mod dynamic;
mod error;
@@ -228,9 +232,24 @@
let std_path = Rc::new(PathBuf::from("std.jsonnet"));
self.run_in_state(|| {
use jsonnet_stdlib::STDLIB_STR;
- if cfg!(feature = "serialized-stdlib") {
+ let mut parsed = false;
+ #[cfg(feature = "codegenerated-stdlib")]
+ if !parsed {
+ parsed = true;
+ #[allow(clippy::all)]
+ let stdlib = {
+ use jsonnet_parser::*;
+ include!(concat!(env!("OUT_DIR"), "/stdlib.rs"))
+ };
+ self.add_parsed_file(std_path.clone(), STDLIB_STR.to_owned().into(), stdlib)
+ .unwrap();
+ }
+
+ #[cfg(feature = "serialized-stdlib")]
+ if !parsed {
+ parsed = true;
self.add_parsed_file(
- std_path,
+ std_path.clone(),
STDLIB_STR.to_owned().into(),
bincode::deserialize(include_bytes!(concat!(
env!("OUT_DIR"),
@@ -239,7 +258,9 @@
.expect("deserialize stdlib"),
)
.unwrap();
- } else {
+ }
+
+ if !parsed {
self.add_file(std_path, STDLIB_STR.to_owned().into())
.unwrap();
}
@@ -662,4 +683,43 @@
"#
);
}
+
+ use test::Bencher;
+
+ // This test is commented out by default, because of huge compilation slowdown
+ // #[bench]
+ // fn bench_codegen(b: &mut Bencher) {
+ // b.iter(|| {
+ // #[allow(clippy::all)]
+ // let stdlib = {
+ // use jsonnet_parser::*;
+ // include!(concat!(env!("OUT_DIR"), "/stdlib.rs"))
+ // };
+ // stdlib
+ // })
+ // }
+
+ #[bench]
+ fn bench_serialize(b: &mut Bencher) {
+ b.iter(|| {
+ bincode::deserialize::<jsonnet_parser::LocExpr>(include_bytes!(concat!(
+ env!("OUT_DIR"),
+ "/stdlib.bincode"
+ )))
+ .expect("deserialize stdlib")
+ })
+ }
+
+ #[bench]
+ fn bench_parse(b: &mut Bencher) {
+ b.iter(|| {
+ jsonnet_parser::parse(
+ jsonnet_stdlib::STDLIB_STR,
+ &jsonnet_parser::ParserSettings {
+ loc_data: true,
+ file_name: Rc::new(PathBuf::from("std.jsonnet")),
+ },
+ )
+ })
+ }
}