Skip to content
Snippets Groups Projects
Commit bb626120 authored by STEVAN Antoine's avatar STEVAN Antoine :crab:
Browse files

split `examples/` into `benchmarks/` and `bins/` (dragoon/komodo!117)

## new structure for the repository
- benchmarks are in `./benchmarks/` and can be run with either `cargo run --package benchmarks --bin <bench>` or the commands in `./benchmarks/README.md`
```
├── Cargo.toml
├── README.md
└── src
    └── bin
        ├── commit.rs
        ├── fec.rs
        ├── linalg.rs
        ├── operations
        │   ├── curve_group.rs
        │   └── field.rs
        ├── recoding.rs
        ├── setup.rs
        └── setup_size.rs
```

- examples are now in `./bins/` as standalone binaries and can be run either with `cargo run --package <pkg>` or with the help of the `cargo bin` command from `.nushell/cargo.nu`
```
├── curves
│   ├── Cargo.toml
│   ├── README.md
│   └── src
│       └── main.rs
├── inbreeding
│   ├── build.nu
│   ├── Cargo.toml
│   ├──...
parent 173a1088
No related branches found
No related tags found
No related merge requests found
Showing
with 104 additions and 98 deletions
File moved
use std log
use error.nu "error throw"
def get-workspace-bins []: nothing -> table<name: string, toml: path> {
open Cargo.toml
| get workspace.members
| each { path join "Cargo.toml" }
| wrap toml
| insert name { get toml | open | get package.name }
}
def get-workspace-bin-names []: nothing -> table<value: string, description: string> {
get-workspace-bins | each {{
value: $in.name,
description: ($in.toml | open | get package.description? | default "")
}}
}
# run a binary from the workspace
export def --wrapped "cargo bin" [
bin: string@get-workspace-bin-names, # the name of the binary to run, press tab to autocomplete
--debug, # run in debug mode
--build, # build the binary in the specified mode
...args: string, # arguments to pass to the binary
] {
let bin_span = (metadata $bin).span
let bins = get-workspace-bins
let bin = $bins | where name == $bin | into record
if $build {
if $debug {
cargo build --manifest-path $bin.toml
} else {
cargo build --release --manifest-path $bin.toml
}
}
let target = if $debug {
"debug"
} else {
"release"
}
let bin = "target" | path join $target $bin.name
if not ($bin | path exists) {
error throw {
err: "binary not found",
label: "hasn't been compiled, compile it with --build",
span: $bin_span,
}
}
^$bin ...$args
}
use error.nu "error throw"
export const WHITE = { r: 1.0, g: 1.0, b: 1.0 }
export const BLACK = { r: 0.0, g: 0.0, b: 0.0 }
export const RED = { r: 1.0, g: 0.0, b: 0.0 }
export const GREEN = { r: 0.0, g: 1.0, b: 0.0 }
export const BLUE = { r: 0.0, g: 0.0, b: 1.0 }
def "error throw" [err: record<err: string, label: string, span: record<start: int, end: int>>] {
error make {
msg: $"(ansi red_bold)($err.err)(ansi reset)",
label: {
text: $err.label,
span: $err.span,
},
}
}
export def "color from-floats" [
r: float,
g: float,
......
export def "error throw" [err: record<err: string, label: string, span: record<start: int, end: int>>] {
error make {
msg: $"(ansi red_bold)($err.err)(ansi reset)",
label: {
text: $err.label,
span: $err.span,
},
}
}
File moved
File moved
File moved
File moved
File moved
File moved
......@@ -20,70 +20,11 @@ tracing-subscriber = "0.3.17"
ark-bls12-381 = "0.4.0"
rand = "0.8.5"
[dev-dependencies]
clap = { version = "4.5.4", features = ["derive"] }
indicatif = "0.17.8"
plnk = { git = "https://gitlab.isae-supaero.fr/a.stevan/plnk", tag = "0.7.0", version = "0.7.0" }
# all the curve dependencies below are used by the `curves` example
ark-bls12-377 = "0.4.0"
ark-bls12-381 = "0.4.0"
ark-bn254 = "0.4.0"
ark-bw6-761 = "0.4.0"
ark-cp6-782 = "0.4.0"
ark-curve25519 = "0.4.0"
ark-ed-on-bls12-377 = "0.4.0"
ark-ed-on-bls12-381 = "0.4.0"
ark-ed-on-bls12-381-bandersnatch = "0.4.0"
ark-ed-on-bn254 = "0.4.0"
ark-ed-on-bw6-761 = "0.4.0"
ark-ed-on-cp6-782 = "0.4.0"
ark-ed-on-mnt4-298 = "0.4.0"
ark-ed-on-mnt4-753 = "0.4.0"
ark-ed25519 = "0.4.0"
ark-mnt4-298 = "0.4.0"
ark-mnt4-753 = "0.4.0"
ark-mnt6-298 = "0.4.0"
ark-mnt6-753 = "0.4.0"
ark-pallas = "0.4.0"
ark-poly-commit = "0.4.0"
ark-secp256k1 = "0.4.0"
ark-secp256r1 = "0.4.0"
ark-secp384r1 = "0.4.0"
ark-secq256k1 = "0.4.0"
ark-vesta = "0.4.0"
[[example]]
name = "bench_commit"
path = "examples/benches/commit.rs"
[[example]]
name = "bench_setup_size"
path = "examples/benches/setup_size.rs"
[[example]]
name = "bench_field_operations"
path = "examples/benches/operations/field.rs"
[[example]]
name = "bench_curve_group_operations"
path = "examples/benches/operations/curve_group.rs"
[[example]]
name = "bench_setup"
path = "examples/benches/setup.rs"
[[example]]
name = "bench_linalg"
path = "examples/benches/linalg.rs"
[[example]]
name = "bench_recoding"
path = "examples/benches/recoding.rs"
[[example]]
name = "bench_fec"
path = "examples/benches/fec.rs"
[[example]]
name = "inbreeding"
path = "examples/inbreeding/mod.rs"
[workspace]
members = [
"benchmarks",
"bins/curves",
"bins/inbreeding",
"bins/rank",
"bins/rng",
]
......@@ -20,5 +20,14 @@ tests for the binary application can also be run with
nu tests/cli.nu
```
## other binaries
Komodo provides a bunch of other binaries that might be interesting of useful to use.
The easiest is to use the `cargo.nu` Nushell module as follows
```bash
use .nushell/cargo.nu "cargo bin"
help cargo bin
```
## the benchmarks
see [the `README`](examples/benches/README.md)
see [the `README`](benchmarks/README.md)
use ../math.nu *
use ../fs.nu check-file
use ../plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ]
use ../../../.nushell/math.nu *
use ../../../.nushell/fs.nu check-file
use ../../../.nushell/plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ]
export def main [data: path, --save: path] {
check-file $data --span (metadata $data).span
......
......@@ -10,7 +10,7 @@ export def main [
return
}
cargo run --release --example bench_commit -- ...[
cargo run --release --package benchmarks --bin commit -- ...[
--nb-measurements $nb_measurements
...$input
--curves ...$curves
......
use ../math.nu *
use ../plot.nu [ into-axis-options, COMMON_OPTIONS ]
use ../fs.nu check-file
use ../plot.nu gplt
use ../../../.nushell/math.nu *
use ../../../.nushell/plot.nu [ into-axis-options, COMMON_OPTIONS ]
use ../../../.nushell/fs.nu check-file
use ../../../.nushell/plot.nu gplt
export def encoding [data: path, --save: path] {
check-file $data --span (metadata $data).span
......
use ../formats.nu *
use ../../../.nushell/formats.nu *
export def main [
--output: path = "./fec.ndjson",
......@@ -16,7 +16,7 @@ export def main [
"" out> $output
for k in $ks {
cargo run --release --example bench_fec -- ...[
cargo run --release --package benchmarks --bin fec -- ...[
--nb-measurements $nb_measurements
...$input
--encoding vandermonde
......
use ../math.nu *
use ../plot.nu [ into-axis-options, COMMON_OPTIONS ]
use ../fs.nu check-file
use ../plot.nu gplt
use ../../../.nushell/math.nu *
use ../../../.nushell/plot.nu [ into-axis-options, COMMON_OPTIONS ]
use ../../../.nushell/fs.nu check-file
use ../../../.nushell/plot.nu gplt
export def main [data: path, --save: path] {
check-file $data --span (metadata $data).span
......
use ../formats.nu *
use ../../../.nushell/formats.nu *
export def main [
--output: path = "./recoding.ndjson",
......@@ -16,7 +16,7 @@ export def main [
"" out> $output
for k in $ks {
cargo run --release --example bench_recoding -- ...[
cargo run --release --package benchmarks --bin recoding -- ...[
--nb-measurements $nb_measurements
...$input
--shards $k
......
use ../math.nu *
use ../fs.nu check-file
use ../plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ]
use ../../../.nushell/math.nu *
use ../../../.nushell/fs.nu check-file
use ../../../.nushell/plot.nu [ into-axis-options, COMMON_OPTIONS, gplt ]
export def main [data: path, --save: path] {
check-file $data --span (metadata $data).span
......
......@@ -10,7 +10,7 @@ export def main [
return
}
cargo run --release --example bench_setup -- ...[
cargo run --release --package benchmarks --bin setup -- ...[
--nb-measurements $nb_measurements
...$input
--curves ...$curves
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment