From 0ec304687edd7c8cfd1a4f47e8645f00d831724a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 11 Feb 2025 17:03:22 +0100 Subject: [PATCH 1/2] Add bitmaps 3.2.1 benchmark --- .../bitmaps-3.2.1/.cargo_vcs_info.json | 6 + .../bitmaps-3.2.1/.github/dependabot.yml | 11 + .../bitmaps-3.2.1/.github/workflows/ci.yml | 35 + .../bitmaps-3.2.1/.gitignore | 3 + .../bitmaps-3.2.1/CHANGELOG.md | 75 + .../bitmaps-3.2.1/CODE_OF_CONDUCT.md | 73 + .../bitmaps-3.2.1/Cargo.lock | 437 +++++ .../bitmaps-3.2.1/Cargo.toml | 36 + .../bitmaps-3.2.1/Cargo.toml.orig | 20 + .../bitmaps-3.2.1/LICENCE.md | 355 ++++ .../bitmaps-3.2.1/README.md | 50 + .../bitmaps-3.2.1/src/bitmap.rs | 830 ++++++++ .../bitmaps-3.2.1/src/lib.rs | 61 + .../bitmaps-3.2.1/src/types.rs | 1693 +++++++++++++++++ 14 files changed, 3685 insertions(+) create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/.cargo_vcs_info.json create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/.github/dependabot.yml create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/.github/workflows/ci.yml create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/.gitignore create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/CHANGELOG.md create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/CODE_OF_CONDUCT.md create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/Cargo.lock create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml.orig create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/LICENCE.md create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/README.md create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/src/bitmap.rs create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/src/lib.rs create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/src/types.rs diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/.cargo_vcs_info.json b/collector/compile-benchmarks/bitmaps-3.2.1/.cargo_vcs_info.json new file mode 100644 index 000000000..bceadeeaa --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "b449cec22ac55c916664a3ae911df2f1fe4eaffd" + }, + "path_in_vcs": "" +} \ No newline at end of file diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/.github/dependabot.yml b/collector/compile-benchmarks/bitmaps-3.2.1/.github/dependabot.yml new file mode 100644 index 000000000..c62d2b8e2 --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/.github/dependabot.yml @@ -0,0 +1,11 @@ +version: 2 +updates: +- package-ecosystem: cargo + directory: "/" + schedule: + interval: daily + open-pull-requests-limit: 10 + ignore: + - dependency-name: proptest-derive + versions: + - 0.3.0 diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/.github/workflows/ci.yml b/collector/compile-benchmarks/bitmaps-3.2.1/.github/workflows/ci.yml new file mode 100644 index 000000000..c677eee22 --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/.github/workflows/ci.yml @@ -0,0 +1,35 @@ +name: Continuous Integration +on: + push: + pull_request: + schedule: + - cron: "0 0 1,15 * *" + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, windows-latest, macOS-latest] + rust: [stable, beta, nightly] + + steps: + - uses: hecrj/setup-rust-action@v1 + with: + rust-version: ${{ matrix.rust }} + - uses: actions/checkout@v1 + - name: Run tests (with all features) + run: cargo test --all-features + - name: Run tests (with no features) + run: cargo test --no-default-features + + clippy: + runs-on: ubuntu-latest + steps: + - uses: hecrj/setup-rust-action@v1 + with: + rust-version: stable + components: clippy + - uses: actions/checkout@v1 + - name: Clippy + run: cargo clippy -- -D warnings diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/.gitignore b/collector/compile-benchmarks/bitmaps-3.2.1/.gitignore new file mode 100644 index 000000000..2f88dbac5 --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/.gitignore @@ -0,0 +1,3 @@ +/target +**/*.rs.bk +Cargo.lock \ No newline at end of file diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/CHANGELOG.md b/collector/compile-benchmarks/bitmaps-3.2.1/CHANGELOG.md new file mode 100644 index 000000000..5f1b5290f --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/CHANGELOG.md @@ -0,0 +1,75 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project +adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). + +## [3.2.1] - 2024-02-01 + +### FIXED + +- `is_full()` no longer panics with full bitmaps of size 32 or multiples + thereof. (#19, #27) + +## [3.2.0] - 2022-04-30 + +### ADDED + +- `Bitmap` now implements `TryFrom<&[u8]>` and `AsRef<[u8]>`, and an `as_bytes()` method was + added, to facilitate conversion to and from byte arrays. +- The iterator is now bidirectional, and `next_index`, `prev_index` and `last_index` methods, with + corresponding `false_index` variants, have been added. (#14) + +## [3.1.0] - 2021-04-30 + +### ADDED + +- The methods `first_false_index()` and `is_full()` have been added to `Bitmap`. (#12) + +### FIXED + +- The previous version broke the `no_std` feature; it has now been restored. (#11) + +## [3.0.0] - 2021-04-26 + +### CHANGED + +- This crate now uses const generics, rather than the `typenum` crate, to encode numerical values + in types. This means you can now use plain integers in the `Bitmap` type, eg. `Bitmap<32>`, + rather than the old `Bitmap`. (#8, #9) + +### ADDED + +- `Bitmap` now implements `Hash`, `Eq`, `PartialOrd` and `Ord`. (#7) +- The `as_value()` method has been added to `Bitmap`, to get a reference to the underlying value. + (#7) +- `bitmaps::Iter` now implements `Clone` and `Debug`. (#4) + +## [2.1.0] - 2020-03-26 + +### ADDED + +- There is now a `std` feature flag, on by default, which you can disable to get a `no_std` crate. + +## [2.0.0] - 2019-09-09 + +### CHANGED + +- `Bits` now does a lot less work, which is now being done instead by the `BitOps` trait on its + storage type. This turns out to improve compilation time quite considerably. If you were using + methods on `Bits` directly, they will have moved to `BitOps`. +- `Debug` now prints a single hex value for the entire bitmap, rather than deferring to the + storage type. +- `Iter` now takes a reference instead of a copy, which is more sensible for larger bitmaps. + +### ADDED + +- `Bitmap` now implements `BitAnd`, `BitOr`, `BitXor`, their equivalent assignation traits, and + `Not`, meaning you can now use bitwise operators on them, even the very big array-of-u128 ones. +- A `Bitmap::mask()` constructor has been added, to construct bitmasks more efficiently, now that + there are bitwise operators to use them with. + +## [1.0.0] - 2019-09-06 + +Initial release. diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/CODE_OF_CONDUCT.md b/collector/compile-benchmarks/bitmaps-3.2.1/CODE_OF_CONDUCT.md new file mode 100644 index 000000000..02a086970 --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/CODE_OF_CONDUCT.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, race, +religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at admin@immutable.rs. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.lock b/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.lock new file mode 100644 index 000000000..f69e8431d --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.lock @@ -0,0 +1,437 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "autocfg" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" + +[[package]] +name = "bit-set" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08807e080ed7f9d5433fa9b275196cfc35414f66a0c79d864dc51a0d825231a3" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e764a1d40d510daf35e07be9eb06e75770908c27d411ee6c92109c9840eaaf7" + +[[package]] +name = "bitflags" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36" + +[[package]] +name = "bitmaps" +version = "3.2.1" +dependencies = [ + "proptest", + "proptest-derive", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "errno" +version = "0.3.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33d852cb9b869c2a9b3df2f71a3074817f01e1844f839a144f5fcef059a4eb5d" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "fastrand" +version = "2.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be" + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.11.0+wasi-snapshot-preview1", +] + +[[package]] +name = "getrandom" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43a49c392881ce6d5c3b8cb70f98717b7c07aabbdff06687b9030dbfbe2725f8" +dependencies = [ + "cfg-if", + "libc", + "wasi 0.13.3+wasi-0.2.2", + "windows-targets", +] + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "libc" +version = "0.2.169" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b5aba8db14291edd000dfcc4d620c7ebfb122c613afb886ca8803fa4e128a20a" + +[[package]] +name = "linux-raw-sys" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", +] + +[[package]] +name = "once_cell" +version = "1.20.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "945462a4b81e43c4e3ba96bd7b49d834c6f61198356aa858733bc4acf3cbe62e" + +[[package]] +name = "ppv-lite86" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04" +dependencies = [ + "zerocopy", +] + +[[package]] +name = "proc-macro2" +version = "1.0.93" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "proptest" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14cae93065090804185d3b75f0bf93b8eeda30c7a9b4a33d3bdb3988d6229e50" +dependencies = [ + "bit-set", + "bit-vec", + "bitflags", + "lazy_static", + "num-traits", + "rand", + "rand_chacha", + "rand_xorshift", + "regex-syntax", + "rusty-fork", + "tempfile", + "unarray", +] + +[[package]] +name = "proptest-derive" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9cf16337405ca084e9c78985114633b6827711d22b9e6ef6c6c0d665eb3f0b6e" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "quick-error" +version = "1.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1d01941d82fa2ab50be1e79e6714289dd7cde78eba4c074bc5a4374f650dfe0" + +[[package]] +name = "quote" +version = "1.0.38" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e4dccaaaf89514f546c693ddc140f729f958c247918a13380cccc6078391acc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "rand" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404" +dependencies = [ + "libc", + "rand_chacha", + "rand_core", +] + +[[package]] +name = "rand_chacha" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" +dependencies = [ + "ppv-lite86", + "rand_core", +] + +[[package]] +name = "rand_core" +version = "0.6.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c" +dependencies = [ + "getrandom 0.2.15", +] + +[[package]] +name = "rand_xorshift" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d25bf25ec5ae4a3f1b92f929810509a2f53d7dca2f50b794ff57e3face536c8f" +dependencies = [ + "rand_core", +] + +[[package]] +name = "regex-syntax" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" + +[[package]] +name = "rustix" +version = "0.38.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fdb5bc1ae2baa591800df16c9ca78619bf65c0488b41b96ccec5d11220d8c154" +dependencies = [ + "bitflags", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "rusty-fork" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cb3dcc6e454c328bb824492db107ab7c0ae8fcffe4ad210136ef014458c1bc4f" +dependencies = [ + "fnv", + "quick-error", + "tempfile", + "wait-timeout", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.98" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "36147f1a48ae0ec2b5b3bc5b537d267457555a10dc06f3dbc8cb11ba3006d3b1" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38c246215d7d24f48ae091a2902398798e05d978b24315d6efbc00ede9a8bb91" +dependencies = [ + "cfg-if", + "fastrand", + "getrandom 0.3.1", + "once_cell", + "rustix", + "windows-sys", +] + +[[package]] +name = "unarray" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eaea85b334db583fe3274d12b4cd1880032beab409c0d774be044d4480ab9a94" + +[[package]] +name = "unicode-ident" +version = "1.0.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034" + +[[package]] +name = "wait-timeout" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ac3b126d3914f9849036f826e054cbabdc8519970b8998ddaf3b5bd3c65f11" +dependencies = [ + "libc", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasi" +version = "0.13.3+wasi-0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26816d2e1a4a36a2940b96c5296ce403917633dff8f3440e9b236ed6f6bacad2" +dependencies = [ + "wit-bindgen-rt", +] + +[[package]] +name = "windows-sys" +version = "0.59.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b" +dependencies = [ + "windows-targets", +] + +[[package]] +name = "windows-targets" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973" +dependencies = [ + "windows_aarch64_gnullvm", + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_gnullvm", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_gnullvm", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469" + +[[package]] +name = "windows_i686_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e9b5ad5ab802e97eb8e295ac6720e509ee4c243f69d781394014ebfe8bbfa0b" + +[[package]] +name = "windows_i686_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66" + +[[package]] +name = "windows_i686_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.52.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "wit-bindgen-rt" +version = "0.33.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3268f3d866458b787f390cf61f4bbb563b922d091359f9608842999eaee3943c" +dependencies = [ + "bitflags", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "byteorder", + "zerocopy-derive", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.98", +] diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml b/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml new file mode 100644 index 000000000..692340dd9 --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml @@ -0,0 +1,36 @@ +# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO +# +# When uploading crates to the registry Cargo will automatically +# "normalize" Cargo.toml files for maximal compatibility +# with all versions of Cargo and also rewrite `path` dependencies +# to registry (e.g., crates.io) dependencies. +# +# If you are reading this file be aware that the original Cargo.toml +# will likely look very different (and much more reasonable). +# See Cargo.toml.orig for the original contents. + +[package] +edition = "2021" +name = "bitmaps" +version = "3.2.1" +authors = ["Bodil Stokke "] +exclude = [ + "release.toml", + "proptest-regressions/**", +] +description = "Fixed size boolean arrays" +documentation = "http://docs.rs/bitmaps" +readme = "./README.md" +categories = ["data-structures"] +license = "MPL-2.0+" +repository = "https://github.com/bodil/bitmaps" + +[dev-dependencies.proptest] +version = "1.0.0" + +[dev-dependencies.proptest-derive] +version = "0.4.0" + +[features] +default = ["std"] +std = [] diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml.orig b/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml.orig new file mode 100644 index 000000000..fb4f618ff --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml.orig @@ -0,0 +1,20 @@ +[package] +name = "bitmaps" +version = "3.2.1" +authors = ["Bodil Stokke "] +edition = "2021" +license = "MPL-2.0+" +description = "Fixed size boolean arrays" +repository = "https://github.com/bodil/bitmaps" +documentation = "http://docs.rs/bitmaps" +readme = "./README.md" +categories = ["data-structures"] +exclude = ["release.toml", "proptest-regressions/**"] + +[features] +default = ["std"] +std = [] + +[dev-dependencies] +proptest = "1.0.0" +proptest-derive = "0.4.0" diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/LICENCE.md b/collector/compile-benchmarks/bitmaps-3.2.1/LICENCE.md new file mode 100644 index 000000000..cd44203cd --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/LICENCE.md @@ -0,0 +1,355 @@ +Mozilla Public License Version 2.0 +================================== + +### 1. Definitions + +**1.1. “Contributor”** + means each individual or legal entity that creates, contributes to + the creation of, or owns Covered Software. + +**1.2. “Contributor Version”** + means the combination of the Contributions of others (if any) used + by a Contributor and that particular Contributor's Contribution. + +**1.3. “Contribution”** + means Covered Software of a particular Contributor. + +**1.4. “Covered Software”** + means Source Code Form to which the initial Contributor has attached + the notice in Exhibit A, the Executable Form of such Source Code + Form, and Modifications of such Source Code Form, in each case + including portions thereof. + +**1.5. “Incompatible With Secondary Licenses”** + means + +* **(a)** that the initial Contributor has attached the notice described + in Exhibit B to the Covered Software; or +* **(b)** that the Covered Software was made available under the terms of + version 1.1 or earlier of the License, but not also under the + terms of a Secondary License. + +**1.6. “Executable Form”** + means any form of the work other than Source Code Form. + +**1.7. “Larger Work”** + means a work that combines Covered Software with other material, in + a separate file or files, that is not Covered Software. + +**1.8. “License”** + means this document. + +**1.9. “Licensable”** + means having the right to grant, to the maximum extent possible, + whether at the time of the initial grant or subsequently, any and + all of the rights conveyed by this License. + +**1.10. “Modifications”** + means any of the following: + +* **(a)** any file in Source Code Form that results from an addition to, + deletion from, or modification of the contents of Covered + Software; or +* **(b)** any new file in Source Code Form that contains any Covered + Software. + +**1.11. “Patent Claims” of a Contributor** + means any patent claim(s), including without limitation, method, + process, and apparatus claims, in any patent Licensable by such + Contributor that would be infringed, but for the grant of the + License, by the making, using, selling, offering for sale, having + made, import, or transfer of either its Contributions or its + Contributor Version. + +**1.12. “Secondary License”** + means either the GNU General Public License, Version 2.0, the GNU + Lesser General Public License, Version 2.1, the GNU Affero General + Public License, Version 3.0, or any later versions of those + licenses. + +**1.13. “Source Code Form”** + means the form of the work preferred for making modifications. + +**1.14. “You” (or “Your”)** + means an individual or a legal entity exercising rights under this + License. For legal entities, “You” includes any entity that + controls, is controlled by, or is under common control with You. For + purposes of this definition, “control” means **(a)** the power, direct + or indirect, to cause the direction or management of such entity, + whether by contract or otherwise, or **(b)** ownership of more than + fifty percent (50%) of the outstanding shares or beneficial + ownership of such entity. + + +### 2. License Grants and Conditions + +#### 2.1. Grants + +Each Contributor hereby grants You a world-wide, royalty-free, +non-exclusive license: + +* **(a)** under intellectual property rights (other than patent or trademark) + Licensable by such Contributor to use, reproduce, make available, + modify, display, perform, distribute, and otherwise exploit its + Contributions, either on an unmodified basis, with Modifications, or + as part of a Larger Work; and +* **(b)** under Patent Claims of such Contributor to make, use, sell, offer + for sale, have made, import, and otherwise transfer either its + Contributions or its Contributor Version. + +#### 2.2. Effective Date + +The licenses granted in Section 2.1 with respect to any Contribution +become effective for each Contribution on the date the Contributor first +distributes such Contribution. + +#### 2.3. Limitations on Grant Scope + +The licenses granted in this Section 2 are the only rights granted under +this License. No additional rights or licenses will be implied from the +distribution or licensing of Covered Software under this License. +Notwithstanding Section 2.1(b) above, no patent license is granted by a +Contributor: + +* **(a)** for any code that a Contributor has removed from Covered Software; + or +* **(b)** for infringements caused by: **(i)** Your and any other third party's + modifications of Covered Software, or **(ii)** the combination of its + Contributions with other software (except as part of its Contributor + Version); or +* **(c)** under Patent Claims infringed by Covered Software in the absence of + its Contributions. + +This License does not grant any rights in the trademarks, service marks, +or logos of any Contributor (except as may be necessary to comply with +the notice requirements in Section 3.4). + +#### 2.4. Subsequent Licenses + +No Contributor makes additional grants as a result of Your choice to +distribute the Covered Software under a subsequent version of this +License (see Section 10.2) or under the terms of a Secondary License (if +permitted under the terms of Section 3.3). + +#### 2.5. Representation + +Each Contributor represents that the Contributor believes its +Contributions are its original creation(s) or it has sufficient rights +to grant the rights to its Contributions conveyed by this License. + +#### 2.6. Fair Use + +This License is not intended to limit any rights You have under +applicable copyright doctrines of fair use, fair dealing, or other +equivalents. + +#### 2.7. Conditions + +Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted +in Section 2.1. + + +### 3. Responsibilities + +#### 3.1. Distribution of Source Form + +All distribution of Covered Software in Source Code Form, including any +Modifications that You create or to which You contribute, must be under +the terms of this License. You must inform recipients that the Source +Code Form of the Covered Software is governed by the terms of this +License, and how they can obtain a copy of this License. You may not +attempt to alter or restrict the recipients' rights in the Source Code +Form. + +#### 3.2. Distribution of Executable Form + +If You distribute Covered Software in Executable Form then: + +* **(a)** such Covered Software must also be made available in Source Code + Form, as described in Section 3.1, and You must inform recipients of + the Executable Form how they can obtain a copy of such Source Code + Form by reasonable means in a timely manner, at a charge no more + than the cost of distribution to the recipient; and + +* **(b)** You may distribute such Executable Form under the terms of this + License, or sublicense it under different terms, provided that the + license for the Executable Form does not attempt to limit or alter + the recipients' rights in the Source Code Form under this License. + +#### 3.3. Distribution of a Larger Work + +You may create and distribute a Larger Work under terms of Your choice, +provided that You also comply with the requirements of this License for +the Covered Software. If the Larger Work is a combination of Covered +Software with a work governed by one or more Secondary Licenses, and the +Covered Software is not Incompatible With Secondary Licenses, this +License permits You to additionally distribute such Covered Software +under the terms of such Secondary License(s), so that the recipient of +the Larger Work may, at their option, further distribute the Covered +Software under the terms of either this License or such Secondary +License(s). + +#### 3.4. Notices + +You may not remove or alter the substance of any license notices +(including copyright notices, patent notices, disclaimers of warranty, +or limitations of liability) contained within the Source Code Form of +the Covered Software, except that You may alter any license notices to +the extent required to remedy known factual inaccuracies. + +#### 3.5. Application of Additional Terms + +You may choose to offer, and to charge a fee for, warranty, support, +indemnity or liability obligations to one or more recipients of Covered +Software. However, You may do so only on Your own behalf, and not on +behalf of any Contributor. You must make it absolutely clear that any +such warranty, support, indemnity, or liability obligation is offered by +You alone, and You hereby agree to indemnify every Contributor for any +liability incurred by such Contributor as a result of warranty, support, +indemnity or liability terms You offer. You may include additional +disclaimers of warranty and limitations of liability specific to any +jurisdiction. + + +### 4. Inability to Comply Due to Statute or Regulation + +If it is impossible for You to comply with any of the terms of this +License with respect to some or all of the Covered Software due to +statute, judicial order, or regulation then You must: **(a)** comply with +the terms of this License to the maximum extent possible; and **(b)** +describe the limitations and the code they affect. Such description must +be placed in a text file included with all distributions of the Covered +Software under this License. Except to the extent prohibited by statute +or regulation, such description must be sufficiently detailed for a +recipient of ordinary skill to be able to understand it. + + +### 5. Termination + +**5.1.** The rights granted under this License will terminate automatically +if You fail to comply with any of its terms. However, if You become +compliant, then the rights granted under this License from a particular +Contributor are reinstated **(a)** provisionally, unless and until such +Contributor explicitly and finally terminates Your grants, and **(b)** on an +ongoing basis, if such Contributor fails to notify You of the +non-compliance by some reasonable means prior to 60 days after You have +come back into compliance. Moreover, Your grants from a particular +Contributor are reinstated on an ongoing basis if such Contributor +notifies You of the non-compliance by some reasonable means, this is the +first time You have received notice of non-compliance with this License +from such Contributor, and You become compliant prior to 30 days after +Your receipt of the notice. + +**5.2.** If You initiate litigation against any entity by asserting a patent +infringement claim (excluding declaratory judgment actions, +counter-claims, and cross-claims) alleging that a Contributor Version +directly or indirectly infringes any patent, then the rights granted to +You by any and all Contributors for the Covered Software under Section +2.1 of this License shall terminate. + +**5.3.** In the event of termination under Sections 5.1 or 5.2 above, all +end user license agreements (excluding distributors and resellers) which +have been validly granted by You or Your distributors under this License +prior to termination shall survive termination. + + +### 6. Disclaimer of Warranty + +> Covered Software is provided under this License on an “as is” +> basis, without warranty of any kind, either expressed, implied, or +> statutory, including, without limitation, warranties that the +> Covered Software is free of defects, merchantable, fit for a +> particular purpose or non-infringing. The entire risk as to the +> quality and performance of the Covered Software is with You. +> Should any Covered Software prove defective in any respect, You +> (not any Contributor) assume the cost of any necessary servicing, +> repair, or correction. This disclaimer of warranty constitutes an +> essential part of this License. No use of any Covered Software is +> authorized under this License except under this disclaimer. + +### 7. Limitation of Liability + +> Under no circumstances and under no legal theory, whether tort +> (including negligence), contract, or otherwise, shall any +> Contributor, or anyone who distributes Covered Software as +> permitted above, be liable to You for any direct, indirect, +> special, incidental, or consequential damages of any character +> including, without limitation, damages for lost profits, loss of +> goodwill, work stoppage, computer failure or malfunction, or any +> and all other commercial damages or losses, even if such party +> shall have been informed of the possibility of such damages. This +> limitation of liability shall not apply to liability for death or +> personal injury resulting from such party's negligence to the +> extent applicable law prohibits such limitation. Some +> jurisdictions do not allow the exclusion or limitation of +> incidental or consequential damages, so this exclusion and +> limitation may not apply to You. + + +### 8. Litigation + +Any litigation relating to this License may be brought only in the +courts of a jurisdiction where the defendant maintains its principal +place of business and such litigation shall be governed by laws of that +jurisdiction, without reference to its conflict-of-law provisions. +Nothing in this Section shall prevent a party's ability to bring +cross-claims or counter-claims. + + +### 9. Miscellaneous + +This License represents the complete agreement concerning the subject +matter hereof. If any provision of this License is held to be +unenforceable, such provision shall be reformed only to the extent +necessary to make it enforceable. Any law or regulation which provides +that the language of a contract shall be construed against the drafter +shall not be used to construe this License against a Contributor. + + +### 10. Versions of the License + +#### 10.1. New Versions + +Mozilla Foundation is the license steward. Except as provided in Section +10.3, no one other than the license steward has the right to modify or +publish new versions of this License. Each version will be given a +distinguishing version number. + +#### 10.2. Effect of New Versions + +You may distribute the Covered Software under the terms of the version +of the License under which You originally received the Covered Software, +or under the terms of any subsequent version published by the license +steward. + +#### 10.3. Modified Versions + +If you create software not governed by this License, and you want to +create a new license for such software, you may create and use a +modified version of this License if you rename the license and remove +any references to the name of the license steward (except to note that +such modified license differs from this License). + +#### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses + +If You choose to distribute Source Code Form that is Incompatible With +Secondary Licenses under the terms of this version of the License, the +notice described in Exhibit B of this License must be attached. + +## Exhibit A - Source Code Form License Notice + + This Source Code Form is subject to the terms of the Mozilla Public + License, v. 2.0. If a copy of the MPL was not distributed with this + file, You can obtain one at http://mozilla.org/MPL/2.0/. + +If it is not possible or desirable to put the notice in a particular +file, then You may include the notice in a location (such as a LICENSE +file in a relevant directory) where a recipient would be likely to look +for such a notice. + +You may add additional accurate notices of copyright ownership. + +## Exhibit B - “Incompatible With Secondary Licenses” Notice + + This Source Code Form is "Incompatible With Secondary Licenses", as + defined by the Mozilla Public License, v. 2.0. diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/README.md b/collector/compile-benchmarks/bitmaps-3.2.1/README.md new file mode 100644 index 000000000..801e48e9c --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/README.md @@ -0,0 +1,50 @@ +# bitmaps + +A fixed size compact boolean array in Rust. + +## Overview + +This crate provides a convenient and efficient way of declaring and working with +fixed size bitmaps in Rust. It was originally split out from the [sized-chunks] +crate and its primary purpose is to support it, but the `Bitmap` type has proven +to be generally useful enough that it was split off into a separate crate. + +## Example + +```rust +use bitmaps::Bitmap; + +fn main() { + let mut bitmap = Bitmap::<10>::new(); + assert_eq!(bitmap.set(5, true), false); + assert_eq!(bitmap.set(5, true), true); + assert_eq!(bitmap.get(5), true); + assert_eq!(bitmap.get(6), false); + assert_eq!(bitmap.len(), 1); + assert_eq!(bitmap.set(3, true), false); + assert_eq!(bitmap.len(), 2); + assert_eq!(bitmap.first_index(), Some(3)); + assert_eq!(bitmap.last_index(), Some(5)); +} +``` + +## Documentation + +* [API docs](https://docs.rs/bitmaps) + +## Licence + +Copyright 2019 Bodil Stokke + +This software is subject to the terms of the Mozilla Public +License, v. 2.0. If a copy of the MPL was not distributed with this +file, You can obtain one at http://mozilla.org/MPL/2.0/. + +## Code of Conduct + +Please note that this project is released with a [Contributor Code of +Conduct][coc]. By participating in this project you agree to abide by its +terms. + +[sized-chunks]: https://github.com/bodil/sized-chunks +[coc]: https://github.com/bodil/bitmaps/blob/master/CODE_OF_CONDUCT.md diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/src/bitmap.rs b/collector/compile-benchmarks/bitmaps-3.2.1/src/bitmap.rs new file mode 100644 index 000000000..1aed29574 --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/src/bitmap.rs @@ -0,0 +1,830 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +use core::fmt::{Debug, Error, Formatter}; +use core::hash::{Hash, Hasher}; +use core::mem::{size_of, MaybeUninit}; +use core::ops::*; + +use crate::types::{BitOps, Bits, BitsImpl}; + +/// A compact array of bits. +/// +/// The type used to store the bitmap will be the minimum unsigned integer type +/// required to fit the number of bits, from `u8` to `u128`. If the size is 1, +/// `bool` is used. If the size exceeds 128, an array of `u128` will be used, +/// sized as appropriately. The maximum supported size is currently 1024, +/// represented by an array `[u128; 8]`. +pub struct Bitmap +where + BitsImpl<{ SIZE }>: Bits, +{ + pub(crate) data: as Bits>::Store, +} + +impl Clone for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn clone(&self) -> Self { + Bitmap::from_value(self.data) + } +} + +impl Copy for Bitmap<{ SIZE }> where BitsImpl<{ SIZE }>: Bits {} + +impl Default for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn default() -> Self { + Bitmap { + data: as Bits>::Store::default(), + } + } +} + +impl PartialEq for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn eq(&self, other: &Self) -> bool { + self.data == other.data + } +} + +impl Eq for Bitmap<{ SIZE }> where BitsImpl<{ SIZE }>: Bits {} + +impl Hash for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, + as Bits>::Store: Hash, +{ + fn hash(&self, state: &mut H) { + self.as_value().hash(state) + } +} + +impl PartialOrd for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, + as Bits>::Store: PartialOrd, +{ + fn partial_cmp(&self, other: &Self) -> Option { + self.as_value().partial_cmp(other.as_value()) + } +} + +impl Ord for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, + as Bits>::Store: Ord, +{ + fn cmp(&self, other: &Self) -> core::cmp::Ordering { + self.as_value().cmp(other.as_value()) + } +} + +#[cfg(feature = "std")] +impl Debug for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!( + f, + "{}", + as Bits>::Store::to_hex(&self.data) + ) + } +} + +impl AsRef<[u8]> for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn as_ref(&self) -> &[u8] { + unsafe { + core::slice::from_raw_parts( + &self.data as *const _ as *const u8, + size_of::< as Bits>::Store>(), + ) + } + } +} + +impl AsMut<[u8]> for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn as_mut(&mut self) -> &mut [u8] { + unsafe { + core::slice::from_raw_parts_mut( + &mut self.data as *mut _ as *mut u8, + size_of::< as Bits>::Store>(), + ) + } + } +} + +impl TryFrom<&[u8]> for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + type Error = (); + + fn try_from(value: &[u8]) -> Result { + if value.len() == size_of::< as Bits>::Store>() { + let mut data: MaybeUninit< as Bits>::Store> = MaybeUninit::uninit(); + let data_ptr: *mut u8 = data.as_mut_ptr().cast(); + Ok(unsafe { + data_ptr.copy_from_nonoverlapping(value.as_ptr(), value.len()); + Self { + data: data.assume_init(), + } + }) + } else { + Err(()) + } + } +} + +#[cfg(not(feature = "std"))] +impl Debug for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { + write!(f, "Bitmap<{}> {{ ... }}", SIZE) + } +} + +impl Bitmap<{ SIZE }> +where + BitsImpl: Bits, +{ + /// Construct a bitmap with every bit set to `false`. + #[inline] + pub fn new() -> Self { + Self::default() + } + + /// Construct a bitmap where every bit with index less than `bits` is + /// `true`, and every other bit is `false`. + #[inline] + pub fn mask(bits: usize) -> Self { + debug_assert!(bits <= SIZE); + Self { + data: as Bits>::Store::make_mask(bits), + } + } + + /// Construct a bitmap from a value of the same type as its backing store. + #[inline] + pub fn from_value(data: as Bits>::Store) -> Self { + Self { data } + } + + /// Convert this bitmap into a value of the type of its backing store. + #[inline] + pub fn into_value(self) -> as Bits>::Store { + self.data + } + + /// Get a reference to this bitmap's backing store. + #[inline] + pub fn as_value(&self) -> & as Bits>::Store { + &self.data + } + + #[inline] + pub fn as_bytes(&self) -> &[u8] { + AsRef::<[u8]>::as_ref(self) + } + + /// Count the number of `true` bits in the bitmap. + #[inline] + pub fn len(self) -> usize { + as Bits>::Store::len(&self.data) + } + + /// Test if the bitmap contains only `false` bits. + #[inline] + pub fn is_empty(self) -> bool { + self.first_index().is_none() + } + + /// Test if the bitmap contains only `true` bits. + #[inline] + pub fn is_full(self) -> bool { + self.first_false_index().is_none() + } + + /// Get the value of the bit at a given index. + #[inline] + pub fn get(self, index: usize) -> bool { + debug_assert!(index < SIZE); + as Bits>::Store::get(&self.data, index) + } + + /// Set the value of the bit at a given index. + /// + /// Returns the previous value of the bit. + #[inline] + pub fn set(&mut self, index: usize, value: bool) -> bool { + debug_assert!(index < SIZE); + as Bits>::Store::set(&mut self.data, index, value) + } + + /// Find the index of the first `true` bit in the bitmap. + #[inline] + pub fn first_index(self) -> Option { + as Bits>::Store::first_index(&self.data) + } + + /// Find the index of the last `true` bit in the bitmap. + #[inline] + pub fn last_index(self) -> Option { + as Bits>::Store::last_index(&self.data) + } + + /// Find the index of the first `true` bit in the bitmap after `index`. + #[inline] + pub fn next_index(self, index: usize) -> Option { + as Bits>::Store::next_index(&self.data, index) + } + + /// Find the index of the last `true` bit in the bitmap before `index`. + #[inline] + pub fn prev_index(self, index: usize) -> Option { + as Bits>::Store::prev_index(&self.data, index) + } + + /// Find the index of the first `false` bit in the bitmap. + #[inline] + pub fn first_false_index(self) -> Option { + as Bits>::corrected_first_false_index(&self.data) + } + + /// Find the index of the last `false` bit in the bitmap. + #[inline] + pub fn last_false_index(self) -> Option { + as Bits>::corrected_last_false_index(&self.data) + } + + /// Find the index of the first `false` bit in the bitmap after `index`. + #[inline] + pub fn next_false_index(self, index: usize) -> Option { + as Bits>::corrected_next_false_index(&self.data, index) + } + + /// Find the index of the first `false` bit in the bitmap before `index`. + #[inline] + pub fn prev_false_index(self, index: usize) -> Option { + as Bits>::Store::prev_false_index(&self.data, index) + } + + /// Invert all the bits in the bitmap. + #[inline] + pub fn invert(&mut self) { + as Bits>::Store::invert(&mut self.data); + } +} + +impl<'a, const SIZE: usize> IntoIterator for &'a Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + type Item = usize; + type IntoIter = Iter<'a, { SIZE }>; + + fn into_iter(self) -> Self::IntoIter { + Iter { + head: None, + tail: Some(SIZE + 1), + data: self, + } + } +} + +impl BitAnd for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + type Output = Self; + fn bitand(mut self, rhs: Self) -> Self::Output { + as Bits>::Store::bit_and(&mut self.data, &rhs.data); + self + } +} + +impl BitOr for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + type Output = Self; + fn bitor(mut self, rhs: Self) -> Self::Output { + as Bits>::Store::bit_or(&mut self.data, &rhs.data); + self + } +} + +impl BitXor for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + type Output = Self; + fn bitxor(mut self, rhs: Self) -> Self::Output { + as Bits>::Store::bit_xor(&mut self.data, &rhs.data); + self + } +} + +impl Not for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + type Output = Self; + fn not(mut self) -> Self::Output { + as Bits>::Store::invert(&mut self.data); + self + } +} + +impl BitAndAssign for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn bitand_assign(&mut self, rhs: Self) { + as Bits>::Store::bit_and(&mut self.data, &rhs.data); + } +} + +impl BitOrAssign for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn bitor_assign(&mut self, rhs: Self) { + as Bits>::Store::bit_or(&mut self.data, &rhs.data); + } +} + +impl BitXorAssign for Bitmap<{ SIZE }> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn bitxor_assign(&mut self, rhs: Self) { + as Bits>::Store::bit_xor(&mut self.data, &rhs.data); + } +} + +impl From<[u128; 2]> for Bitmap<256> { + fn from(data: [u128; 2]) -> Self { + Bitmap { data } + } +} + +impl From<[u128; 3]> for Bitmap<384> { + fn from(data: [u128; 3]) -> Self { + Bitmap { data } + } +} + +impl From<[u128; 4]> for Bitmap<512> { + fn from(data: [u128; 4]) -> Self { + Bitmap { data } + } +} + +impl From<[u128; 5]> for Bitmap<640> { + fn from(data: [u128; 5]) -> Self { + Bitmap { data } + } +} + +impl From<[u128; 6]> for Bitmap<768> { + fn from(data: [u128; 6]) -> Self { + Bitmap { data } + } +} + +impl From<[u128; 7]> for Bitmap<896> { + fn from(data: [u128; 7]) -> Self { + Bitmap { data } + } +} + +impl From<[u128; 8]> for Bitmap<1024> { + fn from(data: [u128; 8]) -> Self { + Bitmap { data } + } +} + +impl From> for [u128; 2] { + fn from(bitmap: Bitmap<256>) -> Self { + bitmap.into_value() + } +} + +impl From> for [u128; 3] { + fn from(bitmap: Bitmap<384>) -> Self { + bitmap.into_value() + } +} + +impl From> for [u128; 4] { + fn from(bitmap: Bitmap<512>) -> Self { + bitmap.into_value() + } +} + +impl From> for [u128; 5] { + fn from(bitmap: Bitmap<640>) -> Self { + bitmap.into_value() + } +} + +impl From> for [u128; 6] { + fn from(bitmap: Bitmap<768>) -> Self { + bitmap.into_value() + } +} + +impl From> for [u128; 7] { + fn from(bitmap: Bitmap<896>) -> Self { + bitmap.into_value() + } +} + +impl From> for [u128; 8] { + fn from(bitmap: Bitmap<1024>) -> Self { + bitmap.into_value() + } +} + +/// An iterator over the indices in a bitmap which are `true`. +/// +/// This yields a sequence of `usize` indices, not their contents (which are +/// always `true` anyway, by definition). +/// +/// # Examples +/// +/// ```rust +/// # use bitmaps::Bitmap; +/// let mut bitmap: Bitmap<10> = Bitmap::new(); +/// bitmap.set(3, true); +/// bitmap.set(5, true); +/// bitmap.set(8, true); +/// let true_indices: Vec = bitmap.into_iter().collect(); +/// assert_eq!(vec![3, 5, 8], true_indices); +/// ``` +#[derive(Clone, Debug)] +pub struct Iter<'a, const SIZE: usize> +where + BitsImpl: Bits, +{ + head: Option, + tail: Option, + data: &'a Bitmap<{ SIZE }>, +} + +impl<'a, const SIZE: usize> Iterator for Iter<'a, SIZE> +where + BitsImpl<{ SIZE }>: Bits, +{ + type Item = usize; + + fn next(&mut self) -> Option { + let result; + + match self.head { + None => { + result = self.data.first_index(); + } + Some(index) => { + if index >= SIZE { + result = None + } else { + result = self.data.next_index(index); + } + } + } + + if let Some(index) = result { + if let Some(tail) = self.tail { + if tail < index { + self.head = Some(SIZE + 1); + self.tail = None; + return None; + } + } else { + // tail is already done + self.head = Some(SIZE + 1); + return None; + } + + self.head = Some(index); + } else { + self.head = Some(SIZE + 1); + } + + result + } +} + +impl<'a, const SIZE: usize> DoubleEndedIterator for Iter<'a, SIZE> +where + BitsImpl<{ SIZE }>: Bits, +{ + fn next_back(&mut self) -> Option { + let result; + + match self.tail { + None => { + result = None; + } + Some(index) => { + if index >= SIZE { + result = self.data.last_index(); + } else { + result = self.data.prev_index(index); + } + } + } + + if let Some(index) = result { + if let Some(head) = self.head { + if head > index { + self.head = Some(SIZE + 1); + self.tail = None; + return None; + } + } + + self.tail = Some(index); + } else { + self.tail = None; + } + + result + } +} + +#[cfg(any(target_arch = "x86", target_arch = "x86_64"))] +#[allow(clippy::cast_ptr_alignment)] +mod x86_arch { + use super::*; + #[cfg(target_arch = "x86")] + use core::arch::x86::*; + #[cfg(target_arch = "x86_64")] + use core::arch::x86_64::*; + + impl Bitmap<128> { + #[target_feature(enable = "sse2")] + pub unsafe fn load_m128i(&self) -> __m128i { + _mm_loadu_si128(&self.data as *const _ as *const __m128i) + } + } + + impl Bitmap<256> { + #[target_feature(enable = "sse2")] + pub unsafe fn load_m128i(&self) -> [__m128i; 2] { + let ptr = &self.data as *const _ as *const __m128i; + [_mm_loadu_si128(ptr), _mm_loadu_si128(ptr.add(1))] + } + + #[target_feature(enable = "avx")] + pub unsafe fn load_m256i(&self) -> __m256i { + _mm256_loadu_si256(&self.data as *const _ as *const __m256i) + } + } + + impl Bitmap<512> { + #[target_feature(enable = "sse2")] + pub unsafe fn load_m128i(&self) -> [__m128i; 4] { + let ptr = &self.data as *const _ as *const __m128i; + [ + _mm_loadu_si128(ptr), + _mm_loadu_si128(ptr.add(1)), + _mm_loadu_si128(ptr.add(2)), + _mm_loadu_si128(ptr.add(3)), + ] + } + + #[target_feature(enable = "avx")] + pub unsafe fn load_m256i(&self) -> [__m256i; 2] { + let ptr = &self.data as *const _ as *const __m256i; + [_mm256_loadu_si256(ptr), _mm256_loadu_si256(ptr.add(1))] + } + } + + impl Bitmap<768> { + #[target_feature(enable = "sse2")] + pub unsafe fn load_m128i(&self) -> [__m128i; 6] { + let ptr = &self.data as *const _ as *const __m128i; + [ + _mm_loadu_si128(ptr), + _mm_loadu_si128(ptr.add(1)), + _mm_loadu_si128(ptr.add(2)), + _mm_loadu_si128(ptr.add(3)), + _mm_loadu_si128(ptr.add(4)), + _mm_loadu_si128(ptr.add(5)), + ] + } + + #[target_feature(enable = "avx")] + pub unsafe fn load_m256i(&self) -> [__m256i; 3] { + let ptr = &self.data as *const _ as *const __m256i; + [ + _mm256_loadu_si256(ptr), + _mm256_loadu_si256(ptr.add(1)), + _mm256_loadu_si256(ptr.add(2)), + ] + } + } + + impl Bitmap<1024> { + #[target_feature(enable = "sse2")] + pub unsafe fn load_m128i(&self) -> [__m128i; 8] { + let ptr = &self.data as *const _ as *const __m128i; + [ + _mm_loadu_si128(ptr), + _mm_loadu_si128(ptr.add(1)), + _mm_loadu_si128(ptr.add(2)), + _mm_loadu_si128(ptr.add(3)), + _mm_loadu_si128(ptr.add(4)), + _mm_loadu_si128(ptr.add(5)), + _mm_loadu_si128(ptr.add(6)), + _mm_loadu_si128(ptr.add(7)), + ] + } + + #[target_feature(enable = "avx")] + pub unsafe fn load_m256i(&self) -> [__m256i; 4] { + let ptr = &self.data as *const _ as *const __m256i; + [ + _mm256_loadu_si256(ptr), + _mm256_loadu_si256(ptr.add(1)), + _mm256_loadu_si256(ptr.add(2)), + _mm256_loadu_si256(ptr.add(3)), + ] + } + } + + impl From<__m128i> for Bitmap<128> { + fn from(data: __m128i) -> Self { + Self { + data: unsafe { core::mem::transmute(data) }, + } + } + } + + impl From<__m256i> for Bitmap<256> { + fn from(data: __m256i) -> Self { + Self { + data: unsafe { core::mem::transmute(data) }, + } + } + } + + impl From> for __m128i { + fn from(data: Bitmap<128>) -> Self { + unsafe { data.load_m128i() } + } + } + + impl From> for __m256i { + fn from(data: Bitmap<256>) -> Self { + unsafe { data.load_m256i() } + } + } + + #[cfg(test)] + mod test { + use super::*; + + struct AlignmentTester + where + BitsImpl: Bits, + { + _byte: u8, + bits: Bitmap, + } + + #[test] + fn load_128() { + let mut t: AlignmentTester<128> = AlignmentTester { + _byte: 0, + bits: Bitmap::new(), + }; + t.bits.set(5, true); + let m = unsafe { t.bits.load_m128i() }; + let mut bits: Bitmap<128> = m.into(); + assert!(bits.set(5, false)); + assert!(bits.is_empty()); + } + + #[test] + fn load_256() { + let mut t: AlignmentTester<256> = AlignmentTester { + _byte: 0, + bits: Bitmap::new(), + }; + t.bits.set(5, true); + let m = unsafe { t.bits.load_m256i() }; + let mut bits: Bitmap<256> = m.into(); + assert!(bits.set(5, false)); + assert!(bits.is_empty()); + } + } +} + +#[cfg(test)] +mod test { + use super::*; + use proptest::collection::btree_set; + use proptest::proptest; + + proptest! { + #[test] + fn get_set_and_iter_61(bits in btree_set(0..61usize, 0..61)) { + let mut bitmap = Bitmap::<61>::new(); + for i in &bits { + bitmap.set(*i, true); + } + for i in 0..61 { + assert_eq!(bitmap.get(i), bits.contains(&i)); + } + assert_eq!(bitmap.first_index(), bits.clone().into_iter().next()); + assert_eq!(bitmap.last_index(), bits.clone().into_iter().next_back()); + assert!(bitmap.into_iter().eq(bits.clone().into_iter())); + assert!(bitmap.into_iter().rev().eq(bits.into_iter().rev())); + } + + #[test] + fn get_set_and_iter_64(bits in btree_set(0..64usize, 0..64)) { + let mut bitmap = Bitmap::<64>::new(); + for i in &bits { + bitmap.set(*i, true); + } + for i in 0..64 { + assert_eq!(bitmap.get(i), bits.contains(&i)); + } + assert_eq!(bitmap.first_index(), bits.clone().into_iter().next()); + assert_eq!(bitmap.last_index(), bits.clone().into_iter().next_back()); + assert!(bitmap.into_iter().eq(bits.clone().into_iter())); + assert!(bitmap.into_iter().rev().eq(bits.into_iter().rev())); + } + + #[test] + fn get_set_and_iter_1024(bits in btree_set(0..1024usize, 0..1024)) { + let mut bitmap = Bitmap::<1024>::new(); + for i in &bits { + bitmap.set(*i, true); + } + for i in 0..1024 { + assert_eq!(bitmap.get(i), bits.contains(&i)); + } + assert_eq!(bitmap.first_index(), bits.clone().into_iter().next()); + assert_eq!(bitmap.last_index(), bits.clone().into_iter().next_back()); + assert!(bitmap.into_iter().eq(bits.clone().into_iter())); + assert!(bitmap.into_iter().rev().eq(bits.into_iter().rev())); + } + + #[test] + fn convert_1024(bits in btree_set(0..1024usize, 0..1024)) { + let mut bitmap = Bitmap::<1024>::new(); + for i in &bits { + bitmap.set(*i, true); + } + let new_bitmap: Bitmap<1024> = TryFrom::try_from(bitmap.as_bytes()).expect("Unable to convert bitmap!"); + assert_eq!(new_bitmap, bitmap); + } + + #[test] + fn mask(shift in 0..=128usize) { + if shift <= 32 { + Bitmap::<32>::mask(shift); + } + + if shift <= 64 { + Bitmap::<64>::mask(shift); + } + + if shift <= 128 { + Bitmap::<128>::mask(shift); + } + } + } + + #[test] + fn mask_limits() { + assert_eq!(Bitmap::<32>::mask(32).into_value(), u32::MAX); + assert_eq!(Bitmap::<64>::mask(64).into_value(), u64::MAX); + assert_eq!(Bitmap::<128>::mask(128).into_value(), u128::MAX); + assert!(Bitmap::<32>::mask(32).is_full()); + assert!(Bitmap::<64>::mask(64).is_full()); + assert!(Bitmap::<128>::mask(128).is_full()); + } +} diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/src/lib.rs b/collector/compile-benchmarks/bitmaps-3.2.1/src/lib.rs new file mode 100644 index 000000000..19211223e --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/src/lib.rs @@ -0,0 +1,61 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#![forbid(rust_2018_idioms)] +#![deny(nonstandard_style)] +#![warn(unreachable_pub)] +#![allow(clippy::missing_safety_doc)] +#![cfg_attr(not(feature = "std"), no_std)] + +//! This crate provides the [`Bitmap`][Bitmap] type as a convenient and +//! efficient way of declaring and working with fixed size bitmaps in Rust. +//! +//! # Examples +//! +//! ```rust +//! # #[macro_use] extern crate bitmaps; +//! # use bitmaps::Bitmap; +//! let mut bitmap: Bitmap<10> = Bitmap::new(); +//! assert_eq!(bitmap.set(5, true), false); +//! assert_eq!(bitmap.set(5, true), true); +//! assert_eq!(bitmap.get(5), true); +//! assert_eq!(bitmap.get(6), false); +//! assert_eq!(bitmap.len(), 1); +//! assert_eq!(bitmap.set(3, true), false); +//! assert_eq!(bitmap.len(), 2); +//! assert_eq!(bitmap.first_index(), Some(3)); +//! ``` +//! +//! # X86 Arch Support +//! +//! On `x86` and `x86_64` architectures, [`Bitmap`][Bitmap]s of size 256, 512, +//! 768 and 1024 gain the [`load_m256i()`][load_m256i] method, which reads the +//! bitmap into an [`__m256i`][m256i] or an array of [`__m256i`][m256i] using +//! [`_mm256_loadu_si256()`][loadu_si256]. [`Bitmap`][Bitmap]s of size 128 as +//! well as the previous gain the [`load_m128i()`][load_m128i] method, which +//! does the same for [`__m128i`][m128i]. +//! +//! In addition, [`Bitmap`][Bitmap] and [`Bitmap`][Bitmap] will have +//! `From` and `Into` implementations for [`__m128i`][m128i] and +//! [`__m256i`][m256i] respectively. +//! +//! Note that alignment is unaffected - your bitmaps will be aligned +//! appropriately for `u128`, not [`__m128i`][m128i] or [`__m256i`][m256i], +//! unless you arrange for it to be otherwise. This may affect the performance +//! of SIMD instructions. +//! +//! [Bitmap]: struct.Bitmap.html +//! [load_m128i]: struct.Bitmap.html#method.load_m128i +//! [load_m256i]: struct.Bitmap.html#method.load_m256i +//! [m128i]: https://doc.rust-lang.org/core/arch/x86_64/struct.__m128i.html +//! [m256i]: https://doc.rust-lang.org/core/arch/x86_64/struct.__m256i.html +//! [loadu_si256]: https://doc.rust-lang.org/core/arch/x86_64/fn._mm256_loadu_si256.html + +mod bitmap; +mod types; + +#[doc(inline)] +pub use crate::bitmap::{Bitmap, Iter}; +#[doc(inline)] +pub use crate::types::{BitOps, Bits, BitsImpl}; diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/src/types.rs b/collector/compile-benchmarks/bitmaps-3.2.1/src/types.rs new file mode 100644 index 000000000..be46b143b --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/src/types.rs @@ -0,0 +1,1693 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, v. 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +use core::fmt::Debug; + +/// A trait that defines generalised operations on a `Bits::Store` type. +pub trait BitOps { + fn get(bits: &Self, index: usize) -> bool; + fn set(bits: &mut Self, index: usize, value: bool) -> bool; + fn len(bits: &Self) -> usize; + fn first_index(bits: &Self) -> Option; + fn first_false_index(bits: &Self) -> Option; + fn last_index(bits: &Self) -> Option; + fn last_false_index(bits: &Self) -> Option; + fn next_index(bits: &Self, index: usize) -> Option; + fn next_false_index(bits: &Self, index: usize) -> Option; + fn prev_index(bits: &Self, index: usize) -> Option; + fn prev_false_index(bits: &Self, index: usize) -> Option; + fn bit_and(bits: &mut Self, other_bits: &Self); + fn bit_or(bits: &mut Self, other_bits: &Self); + fn bit_xor(bits: &mut Self, other_bits: &Self); + fn invert(bits: &mut Self); + fn make_mask(shift: usize) -> Self; + fn bit_size() -> usize; + #[cfg(feature = "std")] + fn to_hex(bits: &Self) -> String; +} + +impl BitOps for bool { + #[inline] + fn get(bits: &Self, index: usize) -> bool { + debug_assert!(index == 0); + *bits + } + + #[inline] + fn set(bits: &mut Self, index: usize, value: bool) -> bool { + debug_assert!(index == 0); + core::mem::replace(bits, value) + } + + #[inline] + fn len(bits: &Self) -> usize { + if *bits { + 1 + } else { + 0 + } + } + + #[inline] + fn first_index(bits: &Self) -> Option { + if *bits { + Some(0) + } else { + None + } + } + + #[inline] + fn first_false_index(bits: &Self) -> Option { + if !*bits { + Some(0) + } else { + None + } + } + + #[inline] + fn last_index(bits: &Self) -> Option { + if *bits { + Some(0) + } else { + None + } + } + + #[inline] + fn last_false_index(bits: &Self) -> Option { + if !*bits { + Some(0) + } else { + None + } + } + #[inline] + fn next_index(bits: &Self, index: usize) -> Option { + debug_assert!(index == 0); + if *bits { + None + } else { + None + } + } + + #[inline] + fn next_false_index(bits: &Self, index: usize) -> Option { + debug_assert!(index == 0); + if *bits { + None + } else { + None + } + } + + #[inline] + fn prev_index(bits: &Self, index: usize) -> Option { + debug_assert!(index == 0); + if *bits { + None + } else { + None + } + } + + #[inline] + fn prev_false_index(bits: &Self, index: usize) -> Option { + debug_assert!(index == 0); + if *bits { + None + } else { + None + } + } + + #[inline] + fn bit_and(bits: &mut Self, other_bits: &Self) { + *bits &= *other_bits; + } + + #[inline] + fn bit_or(bits: &mut Self, other_bits: &Self) { + *bits |= *other_bits; + } + + #[inline] + fn bit_xor(bits: &mut Self, other_bits: &Self) { + *bits ^= *other_bits; + } + + #[inline] + fn invert(bits: &mut Self) { + *bits = !*bits; + } + + #[inline] + fn make_mask(shift: usize) -> Self { + shift > 0 + } + + #[cfg(feature = "std")] + fn to_hex(bits: &Self) -> String { + if *bits { + "1".to_owned() + } else { + "0".to_owned() + } + } + + fn bit_size() -> usize { + 1 + } +} + +macro_rules! bitops_for { + ($target:ty) => { + impl BitOps for $target { + #[inline] + fn get(bits: &Self, index: usize) -> bool { + bits & (1 << index) != 0 + } + + #[inline] + fn set(bits: &mut Self, index: usize, value: bool) -> bool { + let mask = 1 << index; + let prev = *bits & mask; + if value { + *bits |= mask; + } else { + *bits &= !mask; + } + prev != 0 + } + + #[inline] + fn len(bits: &Self) -> usize { + bits.count_ones() as usize + } + + #[inline] + fn first_index(bits: &Self) -> Option { + if *bits == 0 { + None + } else { + Some(bits.trailing_zeros() as usize) + } + } + + #[inline] + fn first_false_index(bits: &Self) -> Option { + if *bits == <$target>::MAX { + None + } else { + Some(bits.trailing_ones() as usize) + } + } + + #[inline] + fn last_index(bits: &Self) -> Option { + if *bits == 0 { + None + } else { + Some(<$target>::BITS as usize - 1 - (bits.leading_zeros() as usize)) + } + } + + #[inline] + fn last_false_index(bits: &Self) -> Option { + if *bits == <$target>::MAX { + None + } else { + Some(<$target>::BITS as usize - 1 - bits.leading_ones() as usize) + } + } + + #[inline] + fn next_index(bits: &Self, index: usize) -> Option { + if *bits == 0 || index >= <$target>::BITS as usize - 1 { + None + } else { + let intermediate = (*bits & (<$target>::MAX.overflowing_shl(1 + index as u32).0)); + + if intermediate == 0 { + None + } else { + Some(intermediate.trailing_zeros() as usize) + } + } + } + + #[inline] + fn next_false_index(bits: &Self, index: usize) -> Option { + if *bits == <$target>::MAX || index >= <$target>::BITS as usize - 1 { + None + } else { + let intermediate = (*bits | ((1 << (index + 1)) - 1)); + + if intermediate == <$target>::MAX { + None + } else { + Some(intermediate.trailing_ones() as usize) + } + } + } + + #[inline] + fn prev_index(bits: &Self, index: usize) -> Option { + if *bits == 0 || index == 0 { + None + } else { + let intermediate = bits & ((1 << index) - 1); + + if intermediate == 0 { + None + } else { + Some(<$target>::BITS as usize - 1 - (intermediate.leading_zeros() as usize)) + } + } + } + + #[inline] + fn prev_false_index(bits: &Self, index: usize) -> Option { + if *bits == <$target>::MAX || index == 0 { + None + } else { + let intermediate = bits | (<$target>::MAX.overflowing_shl(index as u32 - 1).0); + + if intermediate == <$target>::MAX { + None + } else { + Some(<$target>::BITS as usize - 1 - (intermediate.leading_zeros() as usize)) + } + } + } + + #[inline] + fn bit_and(bits: &mut Self, other_bits: &Self) { + *bits &= *other_bits; + } + + #[inline] + fn bit_or(bits: &mut Self, other_bits: &Self) { + *bits |= *other_bits; + } + + #[inline] + fn bit_xor(bits: &mut Self, other_bits: &Self) { + *bits ^= *other_bits; + } + + #[inline] + fn invert(bits: &mut Self) { + *bits = !*bits; + } + + #[inline] + fn make_mask(shift: usize) -> Self { + let (x, overflow) = (1 as Self).overflowing_shl(shift as u32); + if overflow { Self::MAX } else { x - 1 } + } + + #[cfg(feature = "std")] + fn to_hex(bits: &Self) -> String { + format!("{:x}", bits) + } + + #[inline] + fn bit_size() -> usize { + <$target>::BITS as usize + } + } + }; +} + +macro_rules! bitops_for_big { + ($words:expr) => { + impl BitOps for [u128; $words] { + #[inline] + fn get(bits: &Self, index: usize) -> bool { + let word_index = index / 128; + let index = index & 127; + bits[word_index] & (1 << index) != 0 + } + + #[inline] + fn set(bits: &mut Self, index: usize, value: bool) -> bool { + let word_index = index / 128; + let index = index & 127; + + let mask = 1 << (index & 127); + let bits = &mut bits[word_index]; + let prev = *bits & mask; + if value { + *bits |= mask; + } else { + *bits &= !mask; + } + prev != 0 + } + + fn make_mask(shift: usize) -> Self { + let word_index = shift / 128; + let index = shift & 127; + let mut out = [0; $words]; + for (chunk_index, chunk) in out.iter_mut().enumerate() { + if chunk_index < word_index { + *chunk = !0u128; + } else if chunk_index == word_index { + *chunk = (1 << index) - 1; + } else { + return out; + } + } + out + } + + #[inline] + fn len(bits: &Self) -> usize { + bits.iter().fold(0, |acc, next| acc + next.count_ones()) as usize + } + + #[inline] + fn first_index(bits: &Self) -> Option { + for (index, part) in bits.iter().enumerate() { + if *part != 0u128 { + return Some(part.trailing_zeros() as usize + (128 * index)); + } + } + None + } + + #[inline] + fn last_index(bits: &Self) -> Option { + for (index, part) in bits.iter().enumerate().rev() { + if *part != 0u128 { + return Some((128 * index) + ::last_index(part).unwrap()); + } + } + None + } + + #[inline] + fn next_index(bits: &Self, index: usize) -> Option { + let segment: usize = index / 128; + + if (segment >= bits.len()) { + return None + } + + let intermediate = ::next_index(&bits[segment], index % 128); + + if let Some(index) = intermediate { + Some(segment * 128 + index) + } else { + for (index, part) in bits[(segment + 1)..].iter().enumerate() { + if *part != 0u128 { + return Some(128 * (segment + 1 + index) + ::first_index(part).unwrap()); + } + } + + None + } + } + + #[inline] + fn prev_index(bits: &Self, index: usize) -> Option { + let segment: usize = index / 128; + + if (segment >= bits.len()) { + return None + } + + let intermediate = ::prev_index(&bits[segment], index % 128); + + if let Some(index) = intermediate { + Some(segment * 128 + index) + } else { + for (index, part) in bits[..segment].iter().enumerate().rev() { + if *part != 0u128 { + return Some(::last_index(part).unwrap() + (128 * index)); + } + } + None + } + } + + #[inline] + fn first_false_index(bits: &Self) -> Option { + for (index, part) in bits.iter().enumerate() { + if *part != u128::MAX { + return Some(part.trailing_ones() as usize + (128 * index)); + } + } + None + } + + #[inline] + fn last_false_index(bits: &Self) -> Option { + for (index, part) in bits.iter().enumerate().rev() { + if *part != u128::MAX { + return Some(::last_false_index(part).unwrap() + (128 * index)); + } + } + None + } + + #[inline] + fn next_false_index(bits: &Self, index: usize) -> Option { + let segment: usize = index / 128; + + if (segment >= bits.len()) { + return None + } + + let intermediate = ::next_false_index(&bits[segment], index % 128); + + if let Some(index) = intermediate { + Some(segment * 128 + index) + } else { + for (index, part) in bits[(segment + 1)..].iter().enumerate() { + if *part != u128::MAX { + return Some(128 * (segment + 1 + index) + ::first_false_index(part).unwrap()); + } + } + + None + } + } + + #[inline] + fn prev_false_index(bits: &Self, index: usize) -> Option { + let segment: usize = index / 128; + + if (segment >= bits.len()) { + return None + } + + let intermediate = ::prev_false_index(&bits[segment], index % 128); + + if let Some(index) = intermediate { + Some(segment * 128 + index) + } else { + for (index, part) in bits[..segment].iter().enumerate().rev() { + if *part != u128::MAX { + return Some(::last_false_index(part).unwrap() + (128 * index)); + } + } + + None + } + } + + #[inline] + fn bit_and(bits: &mut Self, other_bits: &Self) { + for (left, right) in bits.iter_mut().zip(other_bits.iter()) { + *left &= *right; + } + } + + #[inline] + fn bit_or(bits: &mut Self, other_bits: &Self) { + for (left, right) in bits.iter_mut().zip(other_bits.iter()) { + *left |= *right; + } + } + + #[inline] + fn bit_xor(bits: &mut Self, other_bits: &Self) { + for (left, right) in bits.iter_mut().zip(other_bits.iter()) { + *left ^= *right; + } + } + + #[inline] + fn invert(bits: &mut Self) { + for chunk in bits.iter_mut() { + *chunk = !*chunk; + } + } + + #[cfg(feature = "std")] + fn to_hex(bits: &Self) -> String { + let mut out = String::new(); + for chunk in bits { + out += &format!("{:x}", chunk); + } + out + } + + #[inline] + fn bit_size() -> usize { + (::BITS * $words) as usize + } + } + }; +} + +bitops_for!(u8); +bitops_for!(u16); +bitops_for!(u32); +bitops_for!(u64); +bitops_for!(u128); + +bitops_for_big!(2); +bitops_for_big!(3); +bitops_for_big!(4); +bitops_for_big!(5); +bitops_for_big!(6); +bitops_for_big!(7); +bitops_for_big!(8); + +/// A type level number signifying the number of bits in a bitmap. +/// +/// This trait is implemented for type level numbers from `U1` to `U1024`. +/// +/// # Examples +/// +/// ```rust +/// # #[macro_use] extern crate bitmaps; +/// # use bitmaps::{Bits, BitsImpl}; +/// assert_eq!( +/// std::mem::size_of::< as Bits>::Store>(), +/// std::mem::size_of::() +/// ); +/// ``` +pub trait Bits { + /// The number of bits + const VALUE: usize; + /// A primitive integer type suitable for storing this many bits. + type Store: BitOps + Default + Copy + PartialEq + Debug; + + /// The underlying data type might have some trailing bits, which would + /// result in an invalid value being returned. + /// + /// Thankfully, this only happens for 'false_index'-functions (bits higher + /// than VALUE - 1 cannot be set), and even then only for functions that + /// might seek in that area: that is all forward seeking functions, and + /// the one seeking backwards from the end (last_false_index). + /// prev_false_index is not affected, because the supplied index must be + /// valid, and any index lower than that is also valid. + #[inline] + fn corrected_first_false_index(store: &Self::Store) -> Option { + let result = Self::Store::first_false_index(store); + + if Self::Store::bit_size() == Self::VALUE { + result + } else if let Some(result) = result { + if result >= Self::VALUE { + None + } else { + Some(result) + } + } else { + None + } + } + + /// The underlying data type might have some trailing bits, which would + /// result in an invalid result, so we check against that here. + #[inline] + fn corrected_last_false_index(store: &Self::Store) -> Option { + if Self::Store::bit_size() == Self::VALUE { + Self::Store::last_false_index(store) + } else { + Self::Store::prev_false_index(store, Self::VALUE) + } + } + + #[inline] + fn corrected_next_false_index(store: &Self::Store, index: usize) -> Option { + let result = Self::Store::next_false_index(store, index); + + if Self::Store::bit_size() == Self::VALUE { + result + } else if let Some(result) = result { + if result >= Self::VALUE { + None + } else { + Some(result) + } + } else { + None + } + } +} + +#[doc(hidden)] +pub struct BitsImpl; + +impl Bits for BitsImpl<1> { + const VALUE: usize = 1; + type Store = bool; +} + +macro_rules! bits_for { + ($num:expr, $result:ty) => { + impl Bits for BitsImpl<$num> { + const VALUE: usize = $num; + type Store = $result; + } + }; +} + +macro_rules! bits_for_big { + ($num:expr, $words:expr) => { + impl Bits for BitsImpl<$num> { + const VALUE: usize = $num; + type Store = [u128; $words]; + } + }; +} + +bits_for!(2, u8); +bits_for!(3, u8); +bits_for!(4, u8); +bits_for!(5, u8); +bits_for!(6, u8); +bits_for!(7, u8); +bits_for!(8, u8); +bits_for!(9, u16); +bits_for!(10, u16); +bits_for!(11, u16); +bits_for!(12, u16); +bits_for!(13, u16); +bits_for!(14, u16); +bits_for!(15, u16); +bits_for!(16, u16); +bits_for!(17, u32); +bits_for!(18, u32); +bits_for!(19, u32); +bits_for!(20, u32); +bits_for!(21, u32); +bits_for!(22, u32); +bits_for!(23, u32); +bits_for!(24, u32); +bits_for!(25, u32); +bits_for!(26, u32); +bits_for!(27, u32); +bits_for!(28, u32); +bits_for!(29, u32); +bits_for!(30, u32); +bits_for!(31, u32); +bits_for!(32, u32); +bits_for!(33, u64); +bits_for!(34, u64); +bits_for!(35, u64); +bits_for!(36, u64); +bits_for!(37, u64); +bits_for!(38, u64); +bits_for!(39, u64); +bits_for!(40, u64); +bits_for!(41, u64); +bits_for!(42, u64); +bits_for!(43, u64); +bits_for!(44, u64); +bits_for!(45, u64); +bits_for!(46, u64); +bits_for!(47, u64); +bits_for!(48, u64); +bits_for!(49, u64); +bits_for!(50, u64); +bits_for!(51, u64); +bits_for!(52, u64); +bits_for!(53, u64); +bits_for!(54, u64); +bits_for!(55, u64); +bits_for!(56, u64); +bits_for!(57, u64); +bits_for!(58, u64); +bits_for!(59, u64); +bits_for!(60, u64); +bits_for!(61, u64); +bits_for!(62, u64); +bits_for!(63, u64); +bits_for!(64, u64); +bits_for!(65, u128); +bits_for!(66, u128); +bits_for!(67, u128); +bits_for!(68, u128); +bits_for!(69, u128); +bits_for!(70, u128); +bits_for!(71, u128); +bits_for!(72, u128); +bits_for!(73, u128); +bits_for!(74, u128); +bits_for!(75, u128); +bits_for!(76, u128); +bits_for!(77, u128); +bits_for!(78, u128); +bits_for!(79, u128); +bits_for!(80, u128); +bits_for!(81, u128); +bits_for!(82, u128); +bits_for!(83, u128); +bits_for!(84, u128); +bits_for!(85, u128); +bits_for!(86, u128); +bits_for!(87, u128); +bits_for!(88, u128); +bits_for!(89, u128); +bits_for!(90, u128); +bits_for!(91, u128); +bits_for!(92, u128); +bits_for!(93, u128); +bits_for!(94, u128); +bits_for!(95, u128); +bits_for!(96, u128); +bits_for!(97, u128); +bits_for!(98, u128); +bits_for!(99, u128); +bits_for!(100, u128); +bits_for!(101, u128); +bits_for!(102, u128); +bits_for!(103, u128); +bits_for!(104, u128); +bits_for!(105, u128); +bits_for!(106, u128); +bits_for!(107, u128); +bits_for!(108, u128); +bits_for!(109, u128); +bits_for!(110, u128); +bits_for!(111, u128); +bits_for!(112, u128); +bits_for!(113, u128); +bits_for!(114, u128); +bits_for!(115, u128); +bits_for!(116, u128); +bits_for!(117, u128); +bits_for!(118, u128); +bits_for!(119, u128); +bits_for!(120, u128); +bits_for!(121, u128); +bits_for!(122, u128); +bits_for!(123, u128); +bits_for!(124, u128); +bits_for!(125, u128); +bits_for!(126, u128); +bits_for!(127, u128); +bits_for!(128, u128); + +bits_for_big!(129, 2); +bits_for_big!(130, 2); +bits_for_big!(131, 2); +bits_for_big!(132, 2); +bits_for_big!(133, 2); +bits_for_big!(134, 2); +bits_for_big!(135, 2); +bits_for_big!(136, 2); +bits_for_big!(137, 2); +bits_for_big!(138, 2); +bits_for_big!(139, 2); +bits_for_big!(140, 2); +bits_for_big!(141, 2); +bits_for_big!(142, 2); +bits_for_big!(143, 2); +bits_for_big!(144, 2); +bits_for_big!(145, 2); +bits_for_big!(146, 2); +bits_for_big!(147, 2); +bits_for_big!(148, 2); +bits_for_big!(149, 2); +bits_for_big!(150, 2); +bits_for_big!(151, 2); +bits_for_big!(152, 2); +bits_for_big!(153, 2); +bits_for_big!(154, 2); +bits_for_big!(155, 2); +bits_for_big!(156, 2); +bits_for_big!(157, 2); +bits_for_big!(158, 2); +bits_for_big!(159, 2); +bits_for_big!(160, 2); +bits_for_big!(161, 2); +bits_for_big!(162, 2); +bits_for_big!(163, 2); +bits_for_big!(164, 2); +bits_for_big!(165, 2); +bits_for_big!(166, 2); +bits_for_big!(167, 2); +bits_for_big!(168, 2); +bits_for_big!(169, 2); +bits_for_big!(170, 2); +bits_for_big!(171, 2); +bits_for_big!(172, 2); +bits_for_big!(173, 2); +bits_for_big!(174, 2); +bits_for_big!(175, 2); +bits_for_big!(176, 2); +bits_for_big!(177, 2); +bits_for_big!(178, 2); +bits_for_big!(179, 2); +bits_for_big!(180, 2); +bits_for_big!(181, 2); +bits_for_big!(182, 2); +bits_for_big!(183, 2); +bits_for_big!(184, 2); +bits_for_big!(185, 2); +bits_for_big!(186, 2); +bits_for_big!(187, 2); +bits_for_big!(188, 2); +bits_for_big!(189, 2); +bits_for_big!(190, 2); +bits_for_big!(191, 2); +bits_for_big!(192, 2); +bits_for_big!(193, 2); +bits_for_big!(194, 2); +bits_for_big!(195, 2); +bits_for_big!(196, 2); +bits_for_big!(197, 2); +bits_for_big!(198, 2); +bits_for_big!(199, 2); +bits_for_big!(200, 2); +bits_for_big!(201, 2); +bits_for_big!(202, 2); +bits_for_big!(203, 2); +bits_for_big!(204, 2); +bits_for_big!(205, 2); +bits_for_big!(206, 2); +bits_for_big!(207, 2); +bits_for_big!(208, 2); +bits_for_big!(209, 2); +bits_for_big!(210, 2); +bits_for_big!(211, 2); +bits_for_big!(212, 2); +bits_for_big!(213, 2); +bits_for_big!(214, 2); +bits_for_big!(215, 2); +bits_for_big!(216, 2); +bits_for_big!(217, 2); +bits_for_big!(218, 2); +bits_for_big!(219, 2); +bits_for_big!(220, 2); +bits_for_big!(221, 2); +bits_for_big!(222, 2); +bits_for_big!(223, 2); +bits_for_big!(224, 2); +bits_for_big!(225, 2); +bits_for_big!(226, 2); +bits_for_big!(227, 2); +bits_for_big!(228, 2); +bits_for_big!(229, 2); +bits_for_big!(230, 2); +bits_for_big!(231, 2); +bits_for_big!(232, 2); +bits_for_big!(233, 2); +bits_for_big!(234, 2); +bits_for_big!(235, 2); +bits_for_big!(236, 2); +bits_for_big!(237, 2); +bits_for_big!(238, 2); +bits_for_big!(239, 2); +bits_for_big!(240, 2); +bits_for_big!(241, 2); +bits_for_big!(242, 2); +bits_for_big!(243, 2); +bits_for_big!(244, 2); +bits_for_big!(245, 2); +bits_for_big!(246, 2); +bits_for_big!(247, 2); +bits_for_big!(248, 2); +bits_for_big!(249, 2); +bits_for_big!(250, 2); +bits_for_big!(251, 2); +bits_for_big!(252, 2); +bits_for_big!(253, 2); +bits_for_big!(254, 2); +bits_for_big!(255, 2); +bits_for_big!(256, 2); + +bits_for_big!(257, 3); +bits_for_big!(258, 3); +bits_for_big!(259, 3); +bits_for_big!(260, 3); +bits_for_big!(261, 3); +bits_for_big!(262, 3); +bits_for_big!(263, 3); +bits_for_big!(264, 3); +bits_for_big!(265, 3); +bits_for_big!(266, 3); +bits_for_big!(267, 3); +bits_for_big!(268, 3); +bits_for_big!(269, 3); +bits_for_big!(270, 3); +bits_for_big!(271, 3); +bits_for_big!(272, 3); +bits_for_big!(273, 3); +bits_for_big!(274, 3); +bits_for_big!(275, 3); +bits_for_big!(276, 3); +bits_for_big!(277, 3); +bits_for_big!(278, 3); +bits_for_big!(279, 3); +bits_for_big!(280, 3); +bits_for_big!(281, 3); +bits_for_big!(282, 3); +bits_for_big!(283, 3); +bits_for_big!(284, 3); +bits_for_big!(285, 3); +bits_for_big!(286, 3); +bits_for_big!(287, 3); +bits_for_big!(288, 3); +bits_for_big!(289, 3); +bits_for_big!(290, 3); +bits_for_big!(291, 3); +bits_for_big!(292, 3); +bits_for_big!(293, 3); +bits_for_big!(294, 3); +bits_for_big!(295, 3); +bits_for_big!(296, 3); +bits_for_big!(297, 3); +bits_for_big!(298, 3); +bits_for_big!(299, 3); +bits_for_big!(300, 3); +bits_for_big!(301, 3); +bits_for_big!(302, 3); +bits_for_big!(303, 3); +bits_for_big!(304, 3); +bits_for_big!(305, 3); +bits_for_big!(306, 3); +bits_for_big!(307, 3); +bits_for_big!(308, 3); +bits_for_big!(309, 3); +bits_for_big!(310, 3); +bits_for_big!(311, 3); +bits_for_big!(312, 3); +bits_for_big!(313, 3); +bits_for_big!(314, 3); +bits_for_big!(315, 3); +bits_for_big!(316, 3); +bits_for_big!(317, 3); +bits_for_big!(318, 3); +bits_for_big!(319, 3); +bits_for_big!(320, 3); +bits_for_big!(321, 3); +bits_for_big!(322, 3); +bits_for_big!(323, 3); +bits_for_big!(324, 3); +bits_for_big!(325, 3); +bits_for_big!(326, 3); +bits_for_big!(327, 3); +bits_for_big!(328, 3); +bits_for_big!(329, 3); +bits_for_big!(330, 3); +bits_for_big!(331, 3); +bits_for_big!(332, 3); +bits_for_big!(333, 3); +bits_for_big!(334, 3); +bits_for_big!(335, 3); +bits_for_big!(336, 3); +bits_for_big!(337, 3); +bits_for_big!(338, 3); +bits_for_big!(339, 3); +bits_for_big!(340, 3); +bits_for_big!(341, 3); +bits_for_big!(342, 3); +bits_for_big!(343, 3); +bits_for_big!(344, 3); +bits_for_big!(345, 3); +bits_for_big!(346, 3); +bits_for_big!(347, 3); +bits_for_big!(348, 3); +bits_for_big!(349, 3); +bits_for_big!(350, 3); +bits_for_big!(351, 3); +bits_for_big!(352, 3); +bits_for_big!(353, 3); +bits_for_big!(354, 3); +bits_for_big!(355, 3); +bits_for_big!(356, 3); +bits_for_big!(357, 3); +bits_for_big!(358, 3); +bits_for_big!(359, 3); +bits_for_big!(360, 3); +bits_for_big!(361, 3); +bits_for_big!(362, 3); +bits_for_big!(363, 3); +bits_for_big!(364, 3); +bits_for_big!(365, 3); +bits_for_big!(366, 3); +bits_for_big!(367, 3); +bits_for_big!(368, 3); +bits_for_big!(369, 3); +bits_for_big!(370, 3); +bits_for_big!(371, 3); +bits_for_big!(372, 3); +bits_for_big!(373, 3); +bits_for_big!(374, 3); +bits_for_big!(375, 3); +bits_for_big!(376, 3); +bits_for_big!(377, 3); +bits_for_big!(378, 3); +bits_for_big!(379, 3); +bits_for_big!(380, 3); +bits_for_big!(381, 3); +bits_for_big!(382, 3); +bits_for_big!(383, 3); +bits_for_big!(384, 3); + +bits_for_big!(385, 4); +bits_for_big!(386, 4); +bits_for_big!(387, 4); +bits_for_big!(388, 4); +bits_for_big!(389, 4); +bits_for_big!(390, 4); +bits_for_big!(391, 4); +bits_for_big!(392, 4); +bits_for_big!(393, 4); +bits_for_big!(394, 4); +bits_for_big!(395, 4); +bits_for_big!(396, 4); +bits_for_big!(397, 4); +bits_for_big!(398, 4); +bits_for_big!(399, 4); +bits_for_big!(400, 4); +bits_for_big!(401, 4); +bits_for_big!(402, 4); +bits_for_big!(403, 4); +bits_for_big!(404, 4); +bits_for_big!(405, 4); +bits_for_big!(406, 4); +bits_for_big!(407, 4); +bits_for_big!(408, 4); +bits_for_big!(409, 4); +bits_for_big!(410, 4); +bits_for_big!(411, 4); +bits_for_big!(412, 4); +bits_for_big!(413, 4); +bits_for_big!(414, 4); +bits_for_big!(415, 4); +bits_for_big!(416, 4); +bits_for_big!(417, 4); +bits_for_big!(418, 4); +bits_for_big!(419, 4); +bits_for_big!(420, 4); +bits_for_big!(421, 4); +bits_for_big!(422, 4); +bits_for_big!(423, 4); +bits_for_big!(424, 4); +bits_for_big!(425, 4); +bits_for_big!(426, 4); +bits_for_big!(427, 4); +bits_for_big!(428, 4); +bits_for_big!(429, 4); +bits_for_big!(430, 4); +bits_for_big!(431, 4); +bits_for_big!(432, 4); +bits_for_big!(433, 4); +bits_for_big!(434, 4); +bits_for_big!(435, 4); +bits_for_big!(436, 4); +bits_for_big!(437, 4); +bits_for_big!(438, 4); +bits_for_big!(439, 4); +bits_for_big!(440, 4); +bits_for_big!(441, 4); +bits_for_big!(442, 4); +bits_for_big!(443, 4); +bits_for_big!(444, 4); +bits_for_big!(445, 4); +bits_for_big!(446, 4); +bits_for_big!(447, 4); +bits_for_big!(448, 4); +bits_for_big!(449, 4); +bits_for_big!(450, 4); +bits_for_big!(451, 4); +bits_for_big!(452, 4); +bits_for_big!(453, 4); +bits_for_big!(454, 4); +bits_for_big!(455, 4); +bits_for_big!(456, 4); +bits_for_big!(457, 4); +bits_for_big!(458, 4); +bits_for_big!(459, 4); +bits_for_big!(460, 4); +bits_for_big!(461, 4); +bits_for_big!(462, 4); +bits_for_big!(463, 4); +bits_for_big!(464, 4); +bits_for_big!(465, 4); +bits_for_big!(466, 4); +bits_for_big!(467, 4); +bits_for_big!(468, 4); +bits_for_big!(469, 4); +bits_for_big!(470, 4); +bits_for_big!(471, 4); +bits_for_big!(472, 4); +bits_for_big!(473, 4); +bits_for_big!(474, 4); +bits_for_big!(475, 4); +bits_for_big!(476, 4); +bits_for_big!(477, 4); +bits_for_big!(478, 4); +bits_for_big!(479, 4); +bits_for_big!(480, 4); +bits_for_big!(481, 4); +bits_for_big!(482, 4); +bits_for_big!(483, 4); +bits_for_big!(484, 4); +bits_for_big!(485, 4); +bits_for_big!(486, 4); +bits_for_big!(487, 4); +bits_for_big!(488, 4); +bits_for_big!(489, 4); +bits_for_big!(490, 4); +bits_for_big!(491, 4); +bits_for_big!(492, 4); +bits_for_big!(493, 4); +bits_for_big!(494, 4); +bits_for_big!(495, 4); +bits_for_big!(496, 4); +bits_for_big!(497, 4); +bits_for_big!(498, 4); +bits_for_big!(499, 4); +bits_for_big!(500, 4); +bits_for_big!(501, 4); +bits_for_big!(502, 4); +bits_for_big!(503, 4); +bits_for_big!(504, 4); +bits_for_big!(505, 4); +bits_for_big!(506, 4); +bits_for_big!(507, 4); +bits_for_big!(508, 4); +bits_for_big!(509, 4); +bits_for_big!(510, 4); +bits_for_big!(511, 4); +bits_for_big!(512, 4); + +bits_for_big!(513, 5); +bits_for_big!(514, 5); +bits_for_big!(515, 5); +bits_for_big!(516, 5); +bits_for_big!(517, 5); +bits_for_big!(518, 5); +bits_for_big!(519, 5); +bits_for_big!(520, 5); +bits_for_big!(521, 5); +bits_for_big!(522, 5); +bits_for_big!(523, 5); +bits_for_big!(524, 5); +bits_for_big!(525, 5); +bits_for_big!(526, 5); +bits_for_big!(527, 5); +bits_for_big!(528, 5); +bits_for_big!(529, 5); +bits_for_big!(530, 5); +bits_for_big!(531, 5); +bits_for_big!(532, 5); +bits_for_big!(533, 5); +bits_for_big!(534, 5); +bits_for_big!(535, 5); +bits_for_big!(536, 5); +bits_for_big!(537, 5); +bits_for_big!(538, 5); +bits_for_big!(539, 5); +bits_for_big!(540, 5); +bits_for_big!(541, 5); +bits_for_big!(542, 5); +bits_for_big!(543, 5); +bits_for_big!(544, 5); +bits_for_big!(545, 5); +bits_for_big!(546, 5); +bits_for_big!(547, 5); +bits_for_big!(548, 5); +bits_for_big!(549, 5); +bits_for_big!(550, 5); +bits_for_big!(551, 5); +bits_for_big!(552, 5); +bits_for_big!(553, 5); +bits_for_big!(554, 5); +bits_for_big!(555, 5); +bits_for_big!(556, 5); +bits_for_big!(557, 5); +bits_for_big!(558, 5); +bits_for_big!(559, 5); +bits_for_big!(560, 5); +bits_for_big!(561, 5); +bits_for_big!(562, 5); +bits_for_big!(563, 5); +bits_for_big!(564, 5); +bits_for_big!(565, 5); +bits_for_big!(566, 5); +bits_for_big!(567, 5); +bits_for_big!(568, 5); +bits_for_big!(569, 5); +bits_for_big!(570, 5); +bits_for_big!(571, 5); +bits_for_big!(572, 5); +bits_for_big!(573, 5); +bits_for_big!(574, 5); +bits_for_big!(575, 5); +bits_for_big!(576, 5); +bits_for_big!(577, 5); +bits_for_big!(578, 5); +bits_for_big!(579, 5); +bits_for_big!(580, 5); +bits_for_big!(581, 5); +bits_for_big!(582, 5); +bits_for_big!(583, 5); +bits_for_big!(584, 5); +bits_for_big!(585, 5); +bits_for_big!(586, 5); +bits_for_big!(587, 5); +bits_for_big!(588, 5); +bits_for_big!(589, 5); +bits_for_big!(590, 5); +bits_for_big!(591, 5); +bits_for_big!(592, 5); +bits_for_big!(593, 5); +bits_for_big!(594, 5); +bits_for_big!(595, 5); +bits_for_big!(596, 5); +bits_for_big!(597, 5); +bits_for_big!(598, 5); +bits_for_big!(599, 5); +bits_for_big!(600, 5); +bits_for_big!(601, 5); +bits_for_big!(602, 5); +bits_for_big!(603, 5); +bits_for_big!(604, 5); +bits_for_big!(605, 5); +bits_for_big!(606, 5); +bits_for_big!(607, 5); +bits_for_big!(608, 5); +bits_for_big!(609, 5); +bits_for_big!(610, 5); +bits_for_big!(611, 5); +bits_for_big!(612, 5); +bits_for_big!(613, 5); +bits_for_big!(614, 5); +bits_for_big!(615, 5); +bits_for_big!(616, 5); +bits_for_big!(617, 5); +bits_for_big!(618, 5); +bits_for_big!(619, 5); +bits_for_big!(620, 5); +bits_for_big!(621, 5); +bits_for_big!(622, 5); +bits_for_big!(623, 5); +bits_for_big!(624, 5); +bits_for_big!(625, 5); +bits_for_big!(626, 5); +bits_for_big!(627, 5); +bits_for_big!(628, 5); +bits_for_big!(629, 5); +bits_for_big!(630, 5); +bits_for_big!(631, 5); +bits_for_big!(632, 5); +bits_for_big!(633, 5); +bits_for_big!(634, 5); +bits_for_big!(635, 5); +bits_for_big!(636, 5); +bits_for_big!(637, 5); +bits_for_big!(638, 5); +bits_for_big!(639, 5); +bits_for_big!(640, 5); + +bits_for_big!(641, 6); +bits_for_big!(642, 6); +bits_for_big!(643, 6); +bits_for_big!(644, 6); +bits_for_big!(645, 6); +bits_for_big!(646, 6); +bits_for_big!(647, 6); +bits_for_big!(648, 6); +bits_for_big!(649, 6); +bits_for_big!(650, 6); +bits_for_big!(651, 6); +bits_for_big!(652, 6); +bits_for_big!(653, 6); +bits_for_big!(654, 6); +bits_for_big!(655, 6); +bits_for_big!(656, 6); +bits_for_big!(657, 6); +bits_for_big!(658, 6); +bits_for_big!(659, 6); +bits_for_big!(660, 6); +bits_for_big!(661, 6); +bits_for_big!(662, 6); +bits_for_big!(663, 6); +bits_for_big!(664, 6); +bits_for_big!(665, 6); +bits_for_big!(666, 6); +bits_for_big!(667, 6); +bits_for_big!(668, 6); +bits_for_big!(669, 6); +bits_for_big!(670, 6); +bits_for_big!(671, 6); +bits_for_big!(672, 6); +bits_for_big!(673, 6); +bits_for_big!(674, 6); +bits_for_big!(675, 6); +bits_for_big!(676, 6); +bits_for_big!(677, 6); +bits_for_big!(678, 6); +bits_for_big!(679, 6); +bits_for_big!(680, 6); +bits_for_big!(681, 6); +bits_for_big!(682, 6); +bits_for_big!(683, 6); +bits_for_big!(684, 6); +bits_for_big!(685, 6); +bits_for_big!(686, 6); +bits_for_big!(687, 6); +bits_for_big!(688, 6); +bits_for_big!(689, 6); +bits_for_big!(690, 6); +bits_for_big!(691, 6); +bits_for_big!(692, 6); +bits_for_big!(693, 6); +bits_for_big!(694, 6); +bits_for_big!(695, 6); +bits_for_big!(696, 6); +bits_for_big!(697, 6); +bits_for_big!(698, 6); +bits_for_big!(699, 6); +bits_for_big!(700, 6); +bits_for_big!(701, 6); +bits_for_big!(702, 6); +bits_for_big!(703, 6); +bits_for_big!(704, 6); +bits_for_big!(705, 6); +bits_for_big!(706, 6); +bits_for_big!(707, 6); +bits_for_big!(708, 6); +bits_for_big!(709, 6); +bits_for_big!(710, 6); +bits_for_big!(711, 6); +bits_for_big!(712, 6); +bits_for_big!(713, 6); +bits_for_big!(714, 6); +bits_for_big!(715, 6); +bits_for_big!(716, 6); +bits_for_big!(717, 6); +bits_for_big!(718, 6); +bits_for_big!(719, 6); +bits_for_big!(720, 6); +bits_for_big!(721, 6); +bits_for_big!(722, 6); +bits_for_big!(723, 6); +bits_for_big!(724, 6); +bits_for_big!(725, 6); +bits_for_big!(726, 6); +bits_for_big!(727, 6); +bits_for_big!(728, 6); +bits_for_big!(729, 6); +bits_for_big!(730, 6); +bits_for_big!(731, 6); +bits_for_big!(732, 6); +bits_for_big!(733, 6); +bits_for_big!(734, 6); +bits_for_big!(735, 6); +bits_for_big!(736, 6); +bits_for_big!(737, 6); +bits_for_big!(738, 6); +bits_for_big!(739, 6); +bits_for_big!(740, 6); +bits_for_big!(741, 6); +bits_for_big!(742, 6); +bits_for_big!(743, 6); +bits_for_big!(744, 6); +bits_for_big!(745, 6); +bits_for_big!(746, 6); +bits_for_big!(747, 6); +bits_for_big!(748, 6); +bits_for_big!(749, 6); +bits_for_big!(750, 6); +bits_for_big!(751, 6); +bits_for_big!(752, 6); +bits_for_big!(753, 6); +bits_for_big!(754, 6); +bits_for_big!(755, 6); +bits_for_big!(756, 6); +bits_for_big!(757, 6); +bits_for_big!(758, 6); +bits_for_big!(759, 6); +bits_for_big!(760, 6); +bits_for_big!(761, 6); +bits_for_big!(762, 6); +bits_for_big!(763, 6); +bits_for_big!(764, 6); +bits_for_big!(765, 6); +bits_for_big!(766, 6); +bits_for_big!(767, 6); +bits_for_big!(768, 6); + +bits_for_big!(769, 7); +bits_for_big!(770, 7); +bits_for_big!(771, 7); +bits_for_big!(772, 7); +bits_for_big!(773, 7); +bits_for_big!(774, 7); +bits_for_big!(775, 7); +bits_for_big!(776, 7); +bits_for_big!(777, 7); +bits_for_big!(778, 7); +bits_for_big!(779, 7); +bits_for_big!(780, 7); +bits_for_big!(781, 7); +bits_for_big!(782, 7); +bits_for_big!(783, 7); +bits_for_big!(784, 7); +bits_for_big!(785, 7); +bits_for_big!(786, 7); +bits_for_big!(787, 7); +bits_for_big!(788, 7); +bits_for_big!(789, 7); +bits_for_big!(790, 7); +bits_for_big!(791, 7); +bits_for_big!(792, 7); +bits_for_big!(793, 7); +bits_for_big!(794, 7); +bits_for_big!(795, 7); +bits_for_big!(796, 7); +bits_for_big!(797, 7); +bits_for_big!(798, 7); +bits_for_big!(799, 7); +bits_for_big!(800, 7); +bits_for_big!(801, 7); +bits_for_big!(802, 7); +bits_for_big!(803, 7); +bits_for_big!(804, 7); +bits_for_big!(805, 7); +bits_for_big!(806, 7); +bits_for_big!(807, 7); +bits_for_big!(808, 7); +bits_for_big!(809, 7); +bits_for_big!(810, 7); +bits_for_big!(811, 7); +bits_for_big!(812, 7); +bits_for_big!(813, 7); +bits_for_big!(814, 7); +bits_for_big!(815, 7); +bits_for_big!(816, 7); +bits_for_big!(817, 7); +bits_for_big!(818, 7); +bits_for_big!(819, 7); +bits_for_big!(820, 7); +bits_for_big!(821, 7); +bits_for_big!(822, 7); +bits_for_big!(823, 7); +bits_for_big!(824, 7); +bits_for_big!(825, 7); +bits_for_big!(826, 7); +bits_for_big!(827, 7); +bits_for_big!(828, 7); +bits_for_big!(829, 7); +bits_for_big!(830, 7); +bits_for_big!(831, 7); +bits_for_big!(832, 7); +bits_for_big!(833, 7); +bits_for_big!(834, 7); +bits_for_big!(835, 7); +bits_for_big!(836, 7); +bits_for_big!(837, 7); +bits_for_big!(838, 7); +bits_for_big!(839, 7); +bits_for_big!(840, 7); +bits_for_big!(841, 7); +bits_for_big!(842, 7); +bits_for_big!(843, 7); +bits_for_big!(844, 7); +bits_for_big!(845, 7); +bits_for_big!(846, 7); +bits_for_big!(847, 7); +bits_for_big!(848, 7); +bits_for_big!(849, 7); +bits_for_big!(850, 7); +bits_for_big!(851, 7); +bits_for_big!(852, 7); +bits_for_big!(853, 7); +bits_for_big!(854, 7); +bits_for_big!(855, 7); +bits_for_big!(856, 7); +bits_for_big!(857, 7); +bits_for_big!(858, 7); +bits_for_big!(859, 7); +bits_for_big!(860, 7); +bits_for_big!(861, 7); +bits_for_big!(862, 7); +bits_for_big!(863, 7); +bits_for_big!(864, 7); +bits_for_big!(865, 7); +bits_for_big!(866, 7); +bits_for_big!(867, 7); +bits_for_big!(868, 7); +bits_for_big!(869, 7); +bits_for_big!(870, 7); +bits_for_big!(871, 7); +bits_for_big!(872, 7); +bits_for_big!(873, 7); +bits_for_big!(874, 7); +bits_for_big!(875, 7); +bits_for_big!(876, 7); +bits_for_big!(877, 7); +bits_for_big!(878, 7); +bits_for_big!(879, 7); +bits_for_big!(880, 7); +bits_for_big!(881, 7); +bits_for_big!(882, 7); +bits_for_big!(883, 7); +bits_for_big!(884, 7); +bits_for_big!(885, 7); +bits_for_big!(886, 7); +bits_for_big!(887, 7); +bits_for_big!(888, 7); +bits_for_big!(889, 7); +bits_for_big!(890, 7); +bits_for_big!(891, 7); +bits_for_big!(892, 7); +bits_for_big!(893, 7); +bits_for_big!(894, 7); +bits_for_big!(895, 7); +bits_for_big!(896, 7); + +bits_for_big!(897, 8); +bits_for_big!(898, 8); +bits_for_big!(899, 8); +bits_for_big!(900, 8); +bits_for_big!(901, 8); +bits_for_big!(902, 8); +bits_for_big!(903, 8); +bits_for_big!(904, 8); +bits_for_big!(905, 8); +bits_for_big!(906, 8); +bits_for_big!(907, 8); +bits_for_big!(908, 8); +bits_for_big!(909, 8); +bits_for_big!(910, 8); +bits_for_big!(911, 8); +bits_for_big!(912, 8); +bits_for_big!(913, 8); +bits_for_big!(914, 8); +bits_for_big!(915, 8); +bits_for_big!(916, 8); +bits_for_big!(917, 8); +bits_for_big!(918, 8); +bits_for_big!(919, 8); +bits_for_big!(920, 8); +bits_for_big!(921, 8); +bits_for_big!(922, 8); +bits_for_big!(923, 8); +bits_for_big!(924, 8); +bits_for_big!(925, 8); +bits_for_big!(926, 8); +bits_for_big!(927, 8); +bits_for_big!(928, 8); +bits_for_big!(929, 8); +bits_for_big!(930, 8); +bits_for_big!(931, 8); +bits_for_big!(932, 8); +bits_for_big!(933, 8); +bits_for_big!(934, 8); +bits_for_big!(935, 8); +bits_for_big!(936, 8); +bits_for_big!(937, 8); +bits_for_big!(938, 8); +bits_for_big!(939, 8); +bits_for_big!(940, 8); +bits_for_big!(941, 8); +bits_for_big!(942, 8); +bits_for_big!(943, 8); +bits_for_big!(944, 8); +bits_for_big!(945, 8); +bits_for_big!(946, 8); +bits_for_big!(947, 8); +bits_for_big!(948, 8); +bits_for_big!(949, 8); +bits_for_big!(950, 8); +bits_for_big!(951, 8); +bits_for_big!(952, 8); +bits_for_big!(953, 8); +bits_for_big!(954, 8); +bits_for_big!(955, 8); +bits_for_big!(956, 8); +bits_for_big!(957, 8); +bits_for_big!(958, 8); +bits_for_big!(959, 8); +bits_for_big!(960, 8); +bits_for_big!(961, 8); +bits_for_big!(962, 8); +bits_for_big!(963, 8); +bits_for_big!(964, 8); +bits_for_big!(965, 8); +bits_for_big!(966, 8); +bits_for_big!(967, 8); +bits_for_big!(968, 8); +bits_for_big!(969, 8); +bits_for_big!(970, 8); +bits_for_big!(971, 8); +bits_for_big!(972, 8); +bits_for_big!(973, 8); +bits_for_big!(974, 8); +bits_for_big!(975, 8); +bits_for_big!(976, 8); +bits_for_big!(977, 8); +bits_for_big!(978, 8); +bits_for_big!(979, 8); +bits_for_big!(980, 8); +bits_for_big!(981, 8); +bits_for_big!(982, 8); +bits_for_big!(983, 8); +bits_for_big!(984, 8); +bits_for_big!(985, 8); +bits_for_big!(986, 8); +bits_for_big!(987, 8); +bits_for_big!(988, 8); +bits_for_big!(989, 8); +bits_for_big!(990, 8); +bits_for_big!(991, 8); +bits_for_big!(992, 8); +bits_for_big!(993, 8); +bits_for_big!(994, 8); +bits_for_big!(995, 8); +bits_for_big!(996, 8); +bits_for_big!(997, 8); +bits_for_big!(998, 8); +bits_for_big!(999, 8); +bits_for_big!(1000, 8); +bits_for_big!(1001, 8); +bits_for_big!(1002, 8); +bits_for_big!(1003, 8); +bits_for_big!(1004, 8); +bits_for_big!(1005, 8); +bits_for_big!(1006, 8); +bits_for_big!(1007, 8); +bits_for_big!(1008, 8); +bits_for_big!(1009, 8); +bits_for_big!(1010, 8); +bits_for_big!(1011, 8); +bits_for_big!(1012, 8); +bits_for_big!(1013, 8); +bits_for_big!(1014, 8); +bits_for_big!(1015, 8); +bits_for_big!(1016, 8); +bits_for_big!(1017, 8); +bits_for_big!(1018, 8); +bits_for_big!(1019, 8); +bits_for_big!(1020, 8); +bits_for_big!(1021, 8); +bits_for_big!(1022, 8); +bits_for_big!(1023, 8); +bits_for_big!(1024, 8); From 3b864a9bf1918266ae6afc6352f0bdee228319d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakub=20Ber=C3=A1nek?= Date: Tue, 11 Feb 2025 17:14:23 +0100 Subject: [PATCH 2/2] Add benchmark files and update documentation --- collector/compile-benchmarks/README.md | 3 +++ collector/compile-benchmarks/REUSE.toml | 5 +++++ .../compile-benchmarks/bitmaps-3.2.1/0-println.patch | 12 ++++++++++++ .../compile-benchmarks/bitmaps-3.2.1/Cargo.toml | 2 ++ .../bitmaps-3.2.1/perf-config.json | 4 ++++ 5 files changed, 26 insertions(+) create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/0-println.patch create mode 100644 collector/compile-benchmarks/bitmaps-3.2.1/perf-config.json diff --git a/collector/compile-benchmarks/README.md b/collector/compile-benchmarks/README.md index 21051db03..0ef66012e 100644 --- a/collector/compile-benchmarks/README.md +++ b/collector/compile-benchmarks/README.md @@ -18,6 +18,9 @@ They mostly consist of real-world crates. - **bitmaps-3.1.0**: A bitmaps implementation. Stresses the compiler's trait handling by implementing a trait `Bits` for the type `BitsImpl` for every `N` value from 1 to 1024. +- **bitmaps-3.2.1**: A bitmaps implementation. Stresses the compiler's trait + handling by implementing a trait `Bits` for the type `BitsImpl` for every + `N` value from 1 to 1024. - **cargo-0.60.0**: The Rust package manager. A large program, and an important part of the Rust ecosystem. - **clap-3.1.6**: A command line argument parser library. A crate used by many diff --git a/collector/compile-benchmarks/REUSE.toml b/collector/compile-benchmarks/REUSE.toml index a1e1a312b..d86ef7752 100644 --- a/collector/compile-benchmarks/REUSE.toml +++ b/collector/compile-benchmarks/REUSE.toml @@ -22,6 +22,11 @@ path = "bitmaps-3.1.0/**" SPDX-License-Identifier = "MPL-2.0" SPDX-FileCopyrightText = "Bodil Stokke" +[[annotations]] +path = "bitmaps-3.2.1/**" +SPDX-License-Identifier = "MPL-2.0" +SPDX-FileCopyrightText = "Bodil Stokke" + [[annotations]] path = "cargo-0.60.0/**" SPDX-FileCopyrightText = "The Rust Project Developers (see https://thanks.rust-lang.org)" diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/0-println.patch b/collector/compile-benchmarks/bitmaps-3.2.1/0-println.patch new file mode 100644 index 000000000..fa8da4615 --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/0-println.patch @@ -0,0 +1,12 @@ +diff --git a/src/bitmap.rs b/src/bitmap.rs +index ba5d1b18..9542a890 100644 +--- a/src/bitmap.rs ++++ b/src/bitmap.rs +@@ -27,6 +27,7 @@ where + BitsImpl<{ SIZE }>: Bits, + { + fn clone(&self) -> Self { ++ println!("testing"); + Bitmap::from_value(self.data) + } + } diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml b/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml index 692340dd9..3946fbe2c 100644 --- a/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml +++ b/collector/compile-benchmarks/bitmaps-3.2.1/Cargo.toml @@ -34,3 +34,5 @@ version = "0.4.0" [features] default = ["std"] std = [] + +[workspace] diff --git a/collector/compile-benchmarks/bitmaps-3.2.1/perf-config.json b/collector/compile-benchmarks/bitmaps-3.2.1/perf-config.json new file mode 100644 index 000000000..710581fa8 --- /dev/null +++ b/collector/compile-benchmarks/bitmaps-3.2.1/perf-config.json @@ -0,0 +1,4 @@ +{ + "artifact": "library", + "category": "primary" +}