https://github.com/seanmonstar/num_cpus
Get the number of CPUs in Rust
https://github.com/seanmonstar/num_cpus
rust
Last synced: about 1 year ago
JSON representation
Get the number of CPUs in Rust
- Host: GitHub
- URL: https://github.com/seanmonstar/num_cpus
- Owner: seanmonstar
- License: apache-2.0
- Created: 2015-03-17T01:09:24.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2025-01-29T14:41:27.000Z (over 1 year ago)
- Last Synced: 2025-05-03T00:03:08.724Z (about 1 year ago)
- Topics: rust
- Language: Rust
- Homepage:
- Size: 95.7 KB
- Stars: 600
- Watchers: 14
- Forks: 93
- Open Issues: 33
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# num_cpus
[](https://crates.io/crates/num_cpus)
[](https://github.com/seanmonstar/num_cpus/actions)
- [Documentation](https://docs.rs/num_cpus)
- [CHANGELOG](CHANGELOG.md)
Count the number of CPUs on the current machine.
## Usage
Add to Cargo.toml:
```toml
[dependencies]
num_cpus = "1.0"
```
In your `main.rs` or `lib.rs`:
```rust
extern crate num_cpus;
// count logical cores this process could try to use
let num = num_cpus::get();
```