difftreelog
doc: fix spoiler
in: master
2 files changed
docs/benchmarks.mddiffbeforeafterboth--- a/docs/benchmarks.md
+++ b/docs/benchmarks.md
@@ -169,8 +169,6 @@
```
-</details>
-
Rust (alternative):
```
@@ -201,7 +199,6 @@
```
</details>
-
## Real world
nix/benchmarks.nixdiffbeforeafterboth1{2 lib,3 runCommand,4 jsonnet-bundler,5 cacert,6 stdenv,7 fetchFromGitHub,8 go-jsonnet,9 sjsonnet,10 jsonnet,11 rsjsonnet,12 hyperfine,13 quick ? false,14 jrsonnetVariants,15}:16with lib; let17 jsonnetBench = fetchFromGitHub {18 rev = "v0.19.1";19 owner = "google";20 repo = "jsonnet";21 hash = "sha256-q1MNdbyrx4vvN5woe0o90pPqaNtsZjI5RQ7KJt7rOpU=";22 };23 goJsonnetBench =24 (fetchFromGitHub {25 owner = "google";26 repo = "go-jsonnet";27 rev = "v0.19.1";28 hash = "sha256-FgQYnas0qkIedRAA8ApZXLzEylg6PS6+8zzl7j+yOeI=";29 })30 + "/builtin-benchmarks";31 graalvmBench = fetchFromGitHub {32 owner = "oracle";33 repo = "graal";34 rev = "bc305df3fe587960f7635f0185571500e5988475";35 hash = "sha256-4EKB1b2o4/qtYQ+nqbbs621OJrtjApsAWEBcw5EjrYc=";36 };37 kubePrometheusBench = let38 src = fetchFromGitHub {39 owner = "prometheus-operator";40 repo = "kube-prometheus";41 rev = "d3889807798d1697ea0691f10caf1b6a1997a8bd";42 hash = "sha256-TeYWHzoZAmDp2PzT7EH8XRUcvb3tR8Qfxel7o2QBvIM=";43 };44 in45 runCommand "kube-prometheus-vendor"46 {47 outputHash = "sha256-AGc0dHlD/Ld7I5b1+gOotzJkYrn+bB1VjISdD5NITtw=";48 outputHashMode = "recursive";49 buildInputs = [cacert];50 }51 ''52 mkdir -p $out53 cp -r ${src}/* $out/54 cd $out55 mkdir vendor56 ${jsonnet-bundler}/bin/jb install57 '';5859 # Removes outsiders from the output60 # Useful when comparing performance of different jrsonnet releases61 skipSlow =62 if quick63 then "slow benchmark, but only quick requested"64 else "";65in66 stdenv.mkDerivation {67 name = "benchmarks";68 __impure = true;69 unpackPhase = "true";7071 buildInputs = [72 sjsonnet73 jsonnet74 rsjsonnet75 go-jsonnet7677 hyperfine78 ];7980 installPhase = let81 mkBench = {82 name,83 path,84 omitSource ? false,85 pathIsGenerator ? false,86 skipRustAlternative ? "",87 skipScala ? "",88 skipCpp ? "",89 skipGo ? "",90 vendor ? "",91 }: ''92 echo >> $out93 echo "### ${name}" >> $out94 echo >> $out95 ${optionalString(skipRustAlternative!="")''96 echo "> Note: No results for Rust (alternative), ${skipRustAlternative}" >> $out97 echo >> $out98 ''}99 ${optionalString(skipGo!="")''100 echo "> Note: No results for Go, ${skipGo}" >> $out101 echo >> $out102 ''}103 ${optionalString(skipScala!="")''104 echo "> Note: No results for Scala, ${skipScala}" >> $out105 echo >> $out106 ''}107 ${optionalString(skipCpp!="")''108 echo "> Note: No results for C++, ${skipCpp}" >> $out109 echo >> $out110 ''}111 ${optionalString(!quick&&!omitSource)''112 echo "<details>" >> $out113 echo "<summary>Source</summary>" >> $out114 echo >> $out115 echo "\`\`\`jsonnet" >> $out116 ${optionalStringpathIsGenerator"echo \"// Generator source\" >> $out"}117 cat ${path} >> $out118 echo >> $out119 echo "\`\`\`" >> $out120 echo "</details>" >> $out121 echo >> $out122 ''}123 path=${path}124 ${optionalStringpathIsGenerator''125 go-jsonnet $path > generated.jsonnet126 path=generated.jsonnet127 ''}128 hyperfine -N -w4 -m20 --output=pipe --style=basic --export-markdown result.md \129 ${concatStringsSep" "(forEachjrsonnetVariants(130variant"\"${variant.drv}/bin/jrsonnet $path${optionalString(vendor!="")" -J${vendor}"}\" -n \"Rust${131 ifvariant.name!=""132then" (${variant.name})"133else""134 }\""135))} \136 ${optionalString(skipRustAlternative=="")"\"rsjsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"Rust (alternative, rsjsonnet)\""} \137 ${optionalString(skipGo=="")"\"go-jsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"Go\""} \138 ${optionalString(skipScala=="")"\"sjsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"Scala\""} \139 ${optionalString(skipCpp=="")"\"jsonnet $path${optionalString(vendor!="")" -J ${vendor}"}\" -n \"C++\""}140 cat result.md >> $out141 '';142 in ''143 set -oux144145 temp=$(mktemp -d)146 cd $temp147148 touch $out149 ${optionalString(!quick)''150 cat ${} >> $out151 echo >> $out152153 echo "<details>" >> $out154 echo "<summary>Tested versions</summary>" >> $out155 echo >> $out156 echo Go: $(go-jsonnet --version) >> $out157 echo >> $out158 echo "\`\`\`" >> $out159 go-jsonnet --help >> $out160 echo "\`\`\`" >> $out161 echo >> $out162 echo C++: $(jsonnet --version) >> $out163 echo >> $out164 echo "\`\`\`" >> $out165 jsonnet --help >> $out166 echo "\`\`\`" >> $out167 echo >> $out168 echo Scala: >> $out169 echo >> $out170 echo "\`\`\`" >> $out171 sjsonnet 2>> $out || true172 echo "\`\`\`" >> $out173 echo >> $out174 echo "Rust (alternative):" >> $out175 echo >> $out176 echo "\`\`\`" >> $out177 rsjsonnet --help 2>> $out || true178 echo "\`\`\`" >> $out179 echo >> $out180 echo "</details>" >> $out181 echo >> $out182183 echo >> $out184 ''}185 echo "## Real world" >> $out186 ${mkBench{187name="Graalvm CI";188path="${graalvmBench}/ci.jsonnet";189skipCpp="takes longer than a hour";190skipGo=skipSlow;191skipScala=skipSlow;192}}193 ${mkBench{194name="Kube-prometheus manifests";195vendor="${kubePrometheusBench}/vendor";196path="${kubePrometheusBench}/example.jsonnet";197skipCpp=skipSlow;198skipGo=skipSlow;199skipScala=skipSlow;200}}201202 echo >> $out203 echo "## Benchmarks from C++ jsonnet (/perf_tests)" >> $out204 ${mkBench{205name="Large string join";206path="${jsonnetBench}/perf_tests/large_string_join.jsonnet";207skipScala=skipSlow;208}}209 ${mkBench{210name="Large string template";211omitSource=true;212path="${jsonnetBench}/perf_tests/large_string_template.jsonnet";213skipGo="fails with os stack size exhausion";214skipCpp=skipSlow;215skipScala=skipSlow;216}}217 ${mkBench{218name="Realistic 1";219path="${jsonnetBench}/perf_tests/realistic1.jsonnet";220skipGo=skipSlow;221skipCpp=skipSlow;222skipScala=skipSlow;223}}224 ${mkBench{225name="Realistic 2";226path="${jsonnetBench}/perf_tests/realistic2.jsonnet";227skipGo=skipSlow;228skipCpp=skipSlow;229skipScala=skipSlow;230}}231232 echo >> $out233 echo "## Benchmarks from C++ jsonnet (/benchmarks)" >> $out234 ${mkBench{235name="Tail call";236path="${jsonnetBench}/benchmarks/bench.01.jsonnet";237skipScala=skipSlow;238}}239 ${mkBench{240name="Inheritance recursion";241path="${jsonnetBench}/benchmarks/bench.02.jsonnet";242skipCpp=skipSlow;243skipGo=skipSlow;244}}245 ${mkBench{246name="Simple recursive call";247path="${jsonnetBench}/benchmarks/bench.03.jsonnet";248skipScala=skipSlow;249skipGo=skipSlow;250}}251 ${mkBench{252name="Foldl string concat";253path="${jsonnetBench}/benchmarks/bench.04.jsonnet";254skipCpp=skipSlow;255skipScala=skipSlow;256}}257 ${mkBench{258name="Array sorts";259path="${jsonnetBench}/benchmarks/bench.06.jsonnet";260skipCpp=skipSlow;261# std.assertEqual(reverse(std.range(1, 1000)), sort(std.range(1, 1000), keyF=function(x) -x))262skipScala="sjsonnet doesn't support keyF in std.sort: https://github.com/databricks/sjsonnet/issues/204";263}}264 ${mkBench{265name="Lazy array";266path="${jsonnetBench}/benchmarks/bench.07.jsonnet";267skipGo=skipSlow;268skipScala=skipSlow;269}}270 ${mkBench{271name="Inheritance function recursion";272path="${jsonnetBench}/benchmarks/bench.08.jsonnet";273skipCpp=skipSlow;274skipScala=skipSlow;275}}276 ${mkBench{277name="String strips";278path="${jsonnetBench}/benchmarks/bench.09.jsonnet";279skipCpp=skipSlow;280skipScala=skipSlow;281}}282 ${mkBench{283name="Big object";284path="${jsonnetBench}/benchmarks/gen_big_object.jsonnet";285pathIsGenerator=true;286skipScala=skipSlow;287}}288289 echo >> $out290 echo "## Benchmarks from Go jsonnet (builtins)" >> $out291 ${mkBench{292name="std.base64";293path="${goJsonnetBench}/base64.jsonnet";294skipRustAlternative=skipSlow;295skipCpp=skipSlow;296skipScala=skipSlow;297}}298 ${mkBench{299name="std.base64Decode";300path="${goJsonnetBench}/base64Decode.jsonnet";301skipRustAlternative=skipSlow;302skipCpp=skipSlow;303skipScala=skipSlow;304}}305 ${mkBench{306name="std.base64DecodeBytes";307path="${goJsonnetBench}/base64DecodeBytes.jsonnet";308skipRustAlternative=skipSlow;309skipCpp=skipSlow;310skipGo=skipSlow;311skipScala=skipSlow;312}}313 ${mkBench{314name="std.base64 (byte array)";315path="${goJsonnetBench}/base64_byte_array.jsonnet";316skipRustAlternative=skipSlow;317skipCpp=skipSlow;318skipGo=skipSlow;319skipScala=skipSlow;320}}321 ${mkBench{322name="std.foldl";323path="${goJsonnetBench}/foldl.jsonnet";324skipScala=skipSlow;325}}326 ${mkBench{327name="std.manifestJsonEx";328path="${goJsonnetBench}/manifestJsonEx.jsonnet";329skipScala=skipSlow;330skipCpp=skipSlow;331}}332 ${mkBench{333name="std.manifestTomlEx";334path="${goJsonnetBench}/manifestTomlEx.jsonnet";335skipScala="std.manifestTomlEx is not implemented: https://github.com/databricks/sjsonnet/issues/111";336skipCpp=skipSlow;337}}338 ${mkBench{339name="std.parseInt";340path="${goJsonnetBench}/parseInt.jsonnet";341skipScala=skipSlow;342skipCpp=skipSlow;343}}344 ${mkBench{345name="std.reverse";346path="${goJsonnetBench}/reverse.jsonnet";347skipCpp=skipSlow;348skipGo=skipSlow;349}}350 ${mkBench{351name="std.substr";352path="${goJsonnetBench}/substr.jsonnet";353skipScala=skipSlow;354}}355 ${mkBench{356name="Comparsion for array";357path="${goJsonnetBench}/comparison.jsonnet";358skipScala="array comparsion is not implemented";359skipCpp=skipSlow;360}}361 ${mkBench{362name="Comparsion for primitives";363path="${goJsonnetBench}/comparison2.jsonnet";364skipRustAlternative=skipSlow;365skipCpp="can't run: uses up to 192GB of RAM";366skipGo=skipSlow;367skipScala=skipSlow;368}}369 '';370 }