Skip to content

Commit

Permalink
clean up profiling commits
Browse files Browse the repository at this point in the history
  • Loading branch information
samalws committed Jan 3, 2022
1 parent 410ffa5 commit 8dc3daf
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@ cabal.project.local
crytic-export/
echidna.cabal
*.swp
profiles/
13 changes: 6 additions & 7 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
name = "nixpkgs-unstable-2021-10-15";
url = "https://github.com/nixos/nixpkgs/archive/ee084c02040e864eeeb4cf4f8538d92f7c675671.tar.gz";
sha256 = "sha256:1x8amcixdaw3ryyia32pb706vzhvn5whq9n8jin0qcha5qnm1fnh";
}) {}
}) {},
profiling ? false,
tests ? true
}:

let
Expand Down Expand Up @@ -32,9 +34,6 @@ let

v = "1.7.2";

profilingOn = false;
testsOn = true;

testInputs = [ slither-analyzer solc ];

f = { mkDerivation, aeson, ansi-terminal, base, base16-bytestring, binary
Expand Down Expand Up @@ -64,15 +63,15 @@ let
testHaskellDepends = [ tasty tasty-hunit tasty-quickcheck ];
libraryToolDepends = [ hpack ];
testToolDepends = testInputs;
configureFlags = if profilingOn then [ "--enable-profiling" "--enable-library-profiling" ] else [];
configureFlags = if profiling then [ "--enable-profiling" "--enable-library-profiling" ] else [];
preConfigure = ''
hpack
# re-enable dynamic build for Linux
sed -i -e 's/os(linux)/false/' echidna.cabal
'';
license = pkgs.lib.licenses.agpl3;
doHaddock = false;
doCheck = testsOn;
doCheck = tests;
};

echidna = pkgs.haskellPackages.callPackage f { };
Expand All @@ -84,7 +83,7 @@ let
cabal-install
haskell-language-server
];
nativeBuildInputs = if testsOn then [] else testInputs;
nativeBuildInputs = if tests then [] else testInputs;
};
in
if pkgs.lib.inNixShell
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
# ARGUMENTS:
# $1 - path to echidna-test to run, defaults to "echidna-test"
# $2 - examples folder to profile, defaults to "examples"
# $3 - time limit for each profile, defaults to 60

# TO COMPILE to support profiling:
# nix: set profilingOn to true in default.nix and run nix-build
Expand All @@ -30,6 +31,13 @@ else
examples="$2"
fi

timeLimit=$3
if [ -z "$3" ]; then
timeLimit="60"
else
timeLimit="$3"
fi

# prepare profiles folder and subfolders
for dir in $(find "$examples" -type d); do
mkdir -p "profiles/$dir"
Expand All @@ -42,7 +50,13 @@ doneFiles=0
for file in $(find "$examples" -type f -name "*.sol"); do
doneFiles+=1
echo "$doneFiles/$totalFiles - $file"
# timeout 60 is because some of the files, eg examples/solidity/basic/propGasLimit.sol, can run infinitely
timeout 60 "$echidna" "$file" --format none +RTS -p 2> "profiles/$file.otp"

cfgFile=$(echo "$file" | sed "s/\.sol$/.yml/")
if [ -f "$cfgFile" ]; then
timeout "$timeLimit" "$echidna" "$file" --format none --config "$cfgFile" +RTS -p 2> "profiles/$file.otp"
else
timeout "$timeLimit" "$echidna" "$file" --format none +RTS -p 2> "profiles/$file.otp"
fi

mv echidna-test.prof "profiles/$file.prof"
done

0 comments on commit 8dc3daf

Please sign in to comment.