Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,24 @@ OPTIONS:
-h, --help Display available options
```

### Build
### Nix Build

With [`nix`](https://nixos.org/download/) installed you can run the binary directly from the github repo without cloning it
or installing any other system dependencies manually.
Build both packages using
```sh
nix build github:SoilRos/cpu-latency
```
And the binaries can be found in `results/bin`.

Or run the apps directly:
```sh
nix run github:SoilRos/cpu-latency#default > cpu-latency.csv
nix run github:SoilRos/cpu-latency#cpu-latency-plot -- -i cpu-latency.csv -o cpu-latency.png
```
Thats it. The package definition can be found in `flake.nix`

### Manual Build

This program requires the `hwloc` API in order to bind threads and memory. Make sure to have it available on your system, for example:

Expand Down
16 changes: 16 additions & 0 deletions cpu-latency.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
,,,,,,,,,,,,,,,
8.19047,,,,,,,,,,,,,,,
38.7161,43.3911,,,,,,,,,,,,,,
42.7849,41.2916,8.3785,,,,,,,,,,,,,
40.6754,40.5147,37.9108,39.2531,,,,,,,,,,,,
41.4751,34.3101,40.011,42.3767,10.2224,,,,,,,,,,,
39.167,42.7887,39.6729,40.9829,36.5744,43.2831,,,,,,,,,,
41.0165,40.2607,30.5628,39.7397,31.0674,35.1345,8.02883,,,,,,,,,
41.3245,36.9565,38.4529,37.2639,37.4976,38.8147,38.1139,37.7121,,,,,,,,
40.7089,33.8335,34.8358,35.9822,33.7611,33.0055,37.9209,38.3884,8.08093,,,,,,,
34.9224,40.167,38.8864,37.7187,38.1265,37.6803,37.4194,39.1452,33.8773,39.4251,,,,,,
38.1568,40.4715,39.2691,39.5195,38.0925,38.9488,32.5569,36.6864,39.3567,33.3397,8.19833,,,,,
39.4106,41.1751,35.8036,32.4971,38.3238,39.4311,31.8397,40.3429,32.8858,33.4102,37.5421,31.9478,,,,
39.5997,35.4925,42.9214,39.8932,33.9812,33.2923,36.7748,33.3397,36.9161,38.1162,38.2239,41.5213,7.5154,,,
36.4321,36.5922,40.6733,40.1444,41.5501,32.7673,34.4882,40.2444,31.9862,41.305,38.3385,40.4523,38.9662,41.9738,,
40.9362,35.827,40.7108,41.4788,37.766,33.6702,42.2824,38.1555,37.9444,33.301,40.524,33.7182,41.7284,42.1193,7.84817,
Binary file added cpu-latency.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

51 changes: 51 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
description = "Measure the CPU latency between cores";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

outputs = { self, nixpkgs }:
let
systems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = f:
nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
in
{
packages = forAllSystems (pkgs: {
default = pkgs.stdenv.mkDerivation {
pname = "cpu-latency";
version = "0.1.0";
src = ./.;

nativeBuildInputs = [ pkgs.cmake pkgs.pkg-config ];
buildInputs = [ pkgs.hwloc ];

installPhase = ''
runHook preInstall
install -Dm755 cpu-latency $out/bin/cpu-latency
install -Dm755 ../cpu-latency-plot $out/bin/cpu-latency-plot
runHook postInstall
'';
};
});

apps = forAllSystems (pkgs:
let
system = pkgs.stdenv.hostPlatform.system;
pythonEnv = pkgs.python3.withPackages (ps: [ ps.matplotlib ps.numpy ]);
cpu-latency-plot = pkgs.writeShellScriptBin "cpu-latency-plot" ''
exec ${pythonEnv}/bin/python3 ${self.packages.${system}.default}/bin/cpu-latency-plot "$@"
'';
in
{
default = self.apps.${system}.cpu-latency;
cpu-latency = {
type = "app";
program = "${self.packages.${system}.default}/bin/cpu-latency";
};
cpu-latency-plot = {
type = "app";
program = "${cpu-latency-plot}/bin/cpu-latency-plot";
};
});
};
}