Skip to content

Commit

Permalink
chore: fix go-jsonnet benchmarking
Browse files Browse the repository at this point in the history
  • Loading branch information
CertainLach committed Apr 26, 2024
1 parent a42ba54 commit ab43589
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 11 deletions.
24 changes: 18 additions & 6 deletions nix/benchmarks.nix
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ stdenv.mkDerivation {
unpackPhase = "true";

buildInputs = [
go-jsonnet
sjsonnet
jsonnet
rsjsonnet
go-jsonnet

hyperfine
];
Expand All @@ -79,6 +80,9 @@ stdenv.mkDerivation {
mkBench = { name, path, omitSource ? false, pathIsGenerator ? false, skipScala ? "", skipCpp ? "", skipGo ? "", vendor ? "" }: ''
set -oux
temp=$(mktemp -d)
cd $temp
echo >> $out
echo "### ${name}" >> $out
echo >> $out
Expand Down Expand Up @@ -113,12 +117,12 @@ stdenv.mkDerivation {
''}
hyperfine -N -w4 -m20 --output=pipe --style=basic --export-markdown result.md \
${concatStringsSep " " (forEach jrsonnetVariants (variant:
"\"${variant.drv}/bin/jrsonnet $path ${optionalString (vendor != "") "-J${vendor}"}\" -n \"Rust${if variant.name != "" then " (${variant.name})" else ""}\""
"\"${variant.drv}/bin/jrsonnet $path${optionalString (vendor != "") " -J${vendor}"}\" -n \"Rust${if variant.name != "" then " (${variant.name})" else ""}\""
))} \
"rsjsonnet $path ${optionalString (vendor != "") "-J ${vendor}"}" -n "Rust (alternative, rsjsonnet)"
${optionalString (skipGo == "") "\"go-jsonnet $path ${optionalString (vendor != "") "-J ${vendor}"}\" -n \"Go\""} \
${optionalString (skipScala == "") "\"sjsonnet $path ${optionalString (vendor != "") "-J ${vendor}"}\" -n \"Scala\""} \
${optionalString (skipCpp == "") "\"jsonnet $path ${optionalString (vendor != "") "-J ${vendor}"}\" -n \"C++\""}
"rsjsonnet $path${optionalString (vendor != "") " -J ${vendor}"}" -n "Rust (alternative, rsjsonnet)" \
${optionalString (skipGo == "") "\"go-jsonnet $path${optionalString (vendor != "") " -J ${vendor}"}\" -n \"Go\""} \
${optionalString (skipScala == "") "\"sjsonnet $path${optionalString (vendor != "") " -J ${vendor}"}\" -n \"Scala\""} \
${optionalString (skipCpp == "") "\"jsonnet $path${optionalString (vendor != "") " -J ${vendor}"}\" -n \"C++\""}
cat result.md >> $out
'';
in
Expand Down Expand Up @@ -151,6 +155,14 @@ stdenv.mkDerivation {
echo >> $out
echo "</details>" >> $out
echo >> $out
echo Rust (alternative): >> $out
echo >> $out
echo "\`\`\`" >> $out
rsjsonnet --help 2>> $out || true
echo "\`\`\`" >> $out
echo >> $out
echo "</details>" >> $out
echo >> $out
echo >> $out
''}
Expand Down
13 changes: 8 additions & 5 deletions nix/go-jsonnet.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
{ lib, buildGo119Module, fetchFromGitHub, makeWrapper }:

buildGo119Module rec {
{
buildGoModule,
fetchFromGitHub,
makeWrapper,
}:
buildGoModule rec {
pname = "go-jsonnet";
version = "0.20.0";

Expand All @@ -12,7 +15,7 @@ buildGo119Module rec {
};
vendorHash = "sha256-j1fTOUpLx34TgzW94A/BctLrg9XoTtb3cBizhVJoEEI=";

buildInputs = [ makeWrapper ];
buildInputs = [makeWrapper];

postInstall = ''
mv $out/bin/jsonnet $out/bin/go-jsonnet
Expand All @@ -21,5 +24,5 @@ buildGo119Module rec {

doCheck = false;

subPackages = [ "cmd/jsonnet" ];
subPackages = ["cmd/jsonnet"];
}

0 comments on commit ab43589

Please sign in to comment.