Skip to content

Commit

Permalink
chore: memtrace (#529)
Browse files Browse the repository at this point in the history
  • Loading branch information
rgrinberg authored Oct 13, 2024
1 parent 6f5442a commit 0c89c14
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 21 deletions.
1 change: 1 addition & 0 deletions benchmarks/benchmark.ml
Original file line number Diff line number Diff line change
Expand Up @@ -166,5 +166,6 @@ let () =
Printf.printf "- %s\n" name);
exit 1)
in
Memtrace.trace_if_requested ();
Command_unix.run (Bench.make_command benchmarks)
;;
10 changes: 9 additions & 1 deletion benchmarks/dune
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,13 @@
(:standard -w -58))))

(executables
(libraries re core base stdio threads core_bench core_unix.command_unix)
(libraries
re
core
base
stdio
threads
core_bench
core_unix.command_unix
memtrace)
(names benchmark))
2 changes: 2 additions & 0 deletions benchmarks/memory.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ let benchmarks =
let len = Int.min (String.length str) len in
ignore (Re.execp ~pos:0 ~len re str))))
;;

let () = Command_unix.run (Bench.make_command benchmarks)
63 changes: 43 additions & 20 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,26 @@
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages."${system}";
extraBuildInputs = [ pkgs.ocamlPackages.core_bench ];
checkInputs = with pkgs.ocamlPackages; [
ounit
js_of_ocaml
ppx_expect
pkgs.nodejs-slim
];
devInputs = with pkgs.ocamlPackages; [
ocaml-lsp
pkgs.ocamlformat_0_26_2
];
inherit (pkgs.ocamlPackages) buildDunePackage;
in rec {
packages = rec {
extraBuildInputs = pkgs:
with pkgs.ocamlPackages; [
core_bench
memtrace
];
checkInputs = pkgs:
with pkgs.ocamlPackages; [
ounit
js_of_ocaml
ppx_expect
pkgs.nodejs-slim
];
devInputs = pkgs:
with pkgs.ocamlPackages; [
ocaml-lsp
pkgs.ocamlformat_0_26_2
];
makePackages = pkgs: rec {
default = re;
re = buildDunePackage {
re = pkgs.ocamlPackages.buildDunePackage {
pname = "re";
version = "n/a";
src = ./.;
Expand All @@ -34,13 +37,33 @@
doCheck = true;
};
};
devShells.test = pkgs.mkShell {
ocamlVersionOverlay =
(ocaml: self: super: { ocamlPackages = ocaml super.ocaml-ng; });
makeNixpkgs = ocaml:
nixpkgs.legacyPackages.${system}.appendOverlays [ (ocamlVersionOverlay ocaml) ];
in rec {
# packages = makePackages pkgs;
devShells.test = let
pkgs = makeNixpkgs (ocaml: ocaml.ocamlPackages_5_2);
packages = makePackages pkgs;
in pkgs.mkShell {
inputsFrom = pkgs.lib.attrValues packages;
buildInputs = extraBuildInputs pkgs ++ checkInputs pkgs;
};
devShells.default = let
pkgs = makeNixpkgs (ocaml: ocaml.ocamlPackages_5_2);
packages = makePackages pkgs;
in pkgs.mkShell {
inputsFrom = pkgs.lib.attrValues packages;
buildInputs = extraBuildInputs ++ checkInputs;
buildInputs = extraBuildInputs pkgs ++ devInputs pkgs;
};
devShells.default = pkgs.mkShell {
devShells.memtrace = let
pkgs = makeNixpkgs (ocaml: ocaml.ocamlPackages_4_14);
packages = makePackages pkgs;
in pkgs.mkShell {
inputsFrom = pkgs.lib.attrValues packages;
buildInputs = extraBuildInputs ++ devInputs;
buildInputs = extraBuildInputs pkgs
++ [ pkgs.ocamlPackages.memtrace_viewer ];
};
});
}

0 comments on commit 0c89c14

Please sign in to comment.