Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rebase the TiKV branch on to master #3

Closed
wants to merge 200 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
200 commits
Select commit Hold shift + click to select a range
01e0c73
Add specific path to get raspberry pi CPU temperature
GuillaumeGomez Dec 5, 2019
13a2249
Merge pull request #219 from GuillaumeGomez/handle-more-temperatures
GuillaumeGomez Dec 5, 2019
acd082b
Add more specific refresh methods
GuillaumeGomez Dec 5, 2019
45d7d54
Implement new refresh functions for linux
GuillaumeGomez Dec 5, 2019
28458b3
Add new refresh functions for the C interface
GuillaumeGomez Dec 5, 2019
a1c2466
Add new refresh methods for mac
GuillaumeGomez Dec 5, 2019
494ea16
Add new refresh methods for windows
GuillaumeGomez Dec 5, 2019
baaf333
Add new refresh methods for unknown
GuillaumeGomez Dec 5, 2019
dd520a8
fix RefreshKind examples
GuillaumeGomez Dec 5, 2019
ca614f4
Merge pull request #220 from GuillaumeGomez/more-refreshes
GuillaumeGomez Dec 6, 2019
ac315a0
Greatly improve windows performance
GuillaumeGomez Dec 7, 2019
23d38c2
Merge pull request #221 from GuillaumeGomez/windows-perf
GuillaumeGomez Dec 7, 2019
ea42fb4
Update crate version
GuillaumeGomez Dec 7, 2019
c0c5ff9
Merge pull request #222 from GuillaumeGomez/up-crate-version
GuillaumeGomez Dec 7, 2019
535bafa
Don't get system time more than necessary
GuillaumeGomez Dec 7, 2019
055c6ba
Improve process name getter
GuillaumeGomez Dec 7, 2019
f9c4dd0
Remove unneeded winapi feature
GuillaumeGomez Dec 7, 2019
020b7ad
Improve disks API speed
GuillaumeGomez Dec 7, 2019
f914a54
fmt
GuillaumeGomez Dec 7, 2019
ffb273d
Update crate version
GuillaumeGomez Dec 7, 2019
44a4219
Merge pull request #223 from GuillaumeGomez/windows-improvements
GuillaumeGomez Dec 7, 2019
4afec85
Start implementation to get temperatures
GuillaumeGomez Dec 9, 2019
4597f39
Working version
GuillaumeGomez Dec 9, 2019
5e147e6
clean temperatures code
GuillaumeGomez Dec 10, 2019
cc9d3b3
fmt
GuillaumeGomez Dec 10, 2019
a5a524b
Upgrade version
GuillaumeGomez Dec 10, 2019
7a33f5d
Merge pull request #225 from GuillaumeGomez/windows-temperature
GuillaumeGomez Dec 10, 2019
f7cff91
Add more benchmarks
GuillaumeGomez Dec 10, 2019
cfcb35b
Add benchmarks results for linux
GuillaumeGomez Dec 10, 2019
f717b3b
Add benchmarks results for OSX
GuillaumeGomez Dec 10, 2019
aa27e85
Add benchmarks results for Windows
GuillaumeGomez Dec 10, 2019
ed59d2f
Merge pull request #226 from GuillaumeGomez/benches
GuillaumeGomez Dec 10, 2019
522b1dc
Fix doc example
GuillaumeGomez Dec 13, 2019
4970f57
Merge pull request #228 from GuillaumeGomez/doc-example
GuillaumeGomez Dec 13, 2019
6f523f8
Support wasi
expenses Dec 14, 2019
867c892
Merge pull request #229 from expenses/wasi
GuillaumeGomez Dec 15, 2019
d03a8a2
Clean up linux code
GuillaumeGomez Dec 11, 2019
b64eced
new attempt
GuillaumeGomez Dec 11, 2019
0e6f310
benches
GuillaumeGomez Dec 13, 2019
c3461af
refresh status for existing processes as well
GuillaumeGomez Dec 16, 2019
6aa9a51
more tests
GuillaumeGomez Dec 16, 2019
c847d83
Keep stat File open and fix environment variables get
GuillaumeGomez Dec 16, 2019
f6c775e
remove commented code
GuillaumeGomez Dec 16, 2019
f6750c4
Update benches
GuillaumeGomez Dec 16, 2019
612729e
Update crate version
GuillaumeGomez Dec 16, 2019
ea08050
Merge pull request #230 from GuillaumeGomez/linux-improvements
GuillaumeGomez Dec 16, 2019
c8f0440
Limit potential number of open files at the same time
GuillaumeGomez Jan 4, 2020
137ea0d
Replace Vec::new and HashMap::new calls with with_capacity when possible
GuillaumeGomez Jan 4, 2020
b0272a1
Update linux benchmark results
GuillaumeGomez Jan 4, 2020
ca15f6c
Handle Android separately for REMANING_FILES initialization
GuillaumeGomez Jan 4, 2020
cf1c188
Add Android to the list of supported platforms
GuillaumeGomez Jan 4, 2020
3f8a1ae
Merge pull request #232 from GuillaumeGomez/linux-improvements
GuillaumeGomez Jan 4, 2020
041d57d
Only add once_cell dependency for linux
GuillaumeGomez Jan 4, 2020
d32e08c
Merge pull request #234 from GuillaumeGomez/no-once-cell-osx
GuillaumeGomez Jan 4, 2020
a1805b1
Code cleanup and great performance improvement on refresh_disk_list
GuillaumeGomez Jan 5, 2020
aa47aa9
Create FUNDING.yml
GuillaumeGomez Jan 5, 2020
0053c90
Code cleanup
GuillaumeGomez Jan 5, 2020
36a134a
Greatly improve refresh_temperatures
GuillaumeGomez Jan 5, 2020
6c8c5d4
Clean up temperature source code
GuillaumeGomez Jan 5, 2020
a82f574
Move disk code into its own file
GuillaumeGomez Jan 5, 2020
a08d67d
Clean up process source code
GuillaumeGomez Jan 5, 2020
ed3d68d
Move functions after struct declaration
GuillaumeGomez Jan 5, 2020
4a8e0f8
Greatly improve refresh_processes performance and get more processes …
GuillaumeGomez Jan 6, 2020
e85f719
Fix race condition on disk types
GuillaumeGomez Jan 6, 2020
8ffb4b5
Update OSX benchmark results
GuillaumeGomez Jan 6, 2020
2171479
Merge pull request #235 from GuillaumeGomez/osx-improvements
GuillaumeGomez Jan 6, 2020
223a5f5
Update crate version
GuillaumeGomez Jan 6, 2020
a9af4af
Merge pull request #236 from GuillaumeGomez/update-crate
GuillaumeGomez Jan 6, 2020
5aac788
Replace all "kB" with "KiB"
Jan 9, 2020
403b559
Merge pull request #240 from SimSmith/master
GuillaumeGomez Jan 11, 2020
289636e
Allow to set the open files limit, reduce the limit of maximum open f…
GuillaumeGomez Jan 14, 2020
d5e47ea
Update crate version
GuillaumeGomez Jan 15, 2020
34bba03
Fix FD limiter
GuillaumeGomez Jan 17, 2020
38f578a
Merge pull request #243 from GuillaumeGomez/fds-limit
GuillaumeGomez Jan 17, 2020
c7e6946
Update FUNDING.yml
GuillaumeGomez Jan 22, 2020
db1f7ac
Update FUNDING.yml
GuillaumeGomez Jan 22, 2020
4ae1791
Update FUNDING.yml
GuillaumeGomez Jan 22, 2020
7300479
add functions get_cpu_frequency/get_avg_load
lonng Dec 3, 2019
b33d66e
support retrieve network statistics
lonng Dec 3, 2019
776ff78
support retrieve block device IO statistics
lonng Dec 3, 2019
1f52533
support retrieve system wide configuration list
lonng Dec 3, 2019
97922cb
wrap num_cpus/pnet_datalink/cache_size crates
lonng Dec 4, 2019
b57d44d
Fix io issue with modern Linux versions
Jan 22, 2020
1473e52
Add get_vendor_id function
Jan 22, 2020
159022d
Clean up linux new methods
GuillaumeGomez Jan 26, 2020
751c348
Clean up mac interface
GuillaumeGomez Jan 26, 2020
347ca38
Clean up weird mac API
GuillaumeGomez Jan 26, 2020
029d071
Add new methods for windows
GuillaumeGomez Jan 26, 2020
2101ee4
Implement API for unknown as well
GuillaumeGomez Jan 26, 2020
7512696
rename load_avg method
GuillaumeGomez Jan 26, 2020
564ab54
Add new methods into examples as well
GuillaumeGomez Jan 26, 2020
4e04017
Handle CTRL+D in example
GuillaumeGomez Jan 26, 2020
338e3ed
windows
GuillaumeGomez Jan 26, 2020
d05a3a4
Remove unneeded dependencies and unused functions
GuillaumeGomez Jan 26, 2020
e70594d
remove windows warnings
GuillaumeGomez Jan 26, 2020
f8d766a
Add code examples
GuillaumeGomez Jan 26, 2020
a3bf93f
Clean up simple.rs
GuillaumeGomez Jan 28, 2020
13b9154
Add frequency and vendor id on windows
GuillaumeGomez Jan 28, 2020
40c6c8a
Add get_brand method for processor
GuillaumeGomez Jan 28, 2020
68d64df
Add brand for linux
GuillaumeGomez Jan 28, 2020
7bd812a
Add brand for mac
GuillaumeGomez Jan 28, 2020
4682a42
Add brand for windows
GuillaumeGomez Jan 28, 2020
34fea68
fmt
GuillaumeGomez Jan 28, 2020
d7b4a35
Add brand command and rename proc to procs
GuillaumeGomez Jan 28, 2020
f53b7bc
Add get_brand for unknown
GuillaumeGomez Jan 28, 2020
983c87b
remove too general io and net files
GuillaumeGomez Jan 29, 2020
b1277ba
Rework network interface
GuillaumeGomez Jan 29, 2020
ab059a7
Update to new Networks type
GuillaumeGomez Jan 30, 2020
383f944
speed up networks refresh
GuillaumeGomez Jan 30, 2020
3a74384
Implement new Networks system on mac
GuillaumeGomez Jan 31, 2020
23256e8
Improve network example
GuillaumeGomez Jan 31, 2020
2ab3bf4
replace .insert by .insert_with
GuillaumeGomez Jan 31, 2020
42067a7
Fix doc
GuillaumeGomez Jan 31, 2020
bebc32b
Update c_interface
GuillaumeGomez Jan 31, 2020
7965eda
fix C example
GuillaumeGomez Jan 31, 2020
0277a0a
Start network refactoring on windows
GuillaumeGomez Feb 2, 2020
2333ca7
Greatly rework network API
GuillaumeGomez Feb 2, 2020
4da4d6e
Fix windows network part and remove software interfaces
GuillaumeGomez Feb 3, 2020
1dabf92
Improve network display in example
GuillaumeGomez Feb 3, 2020
b16d9c9
Add load average support for windows
GuillaumeGomez Feb 4, 2020
1691e9f
Remove duplicate calls on refresh
GuillaumeGomez Feb 4, 2020
b3f6c3c
Add networks_list entry for RefreshKind
GuillaumeGomez Feb 4, 2020
088bf1d
renaming for some methods
GuillaumeGomez Feb 4, 2020
d4d47f1
Update docs and benchmarks
GuillaumeGomez Feb 4, 2020
73dbc0e
Update benchmarks results for windows
GuillaumeGomez Feb 4, 2020
bb7388f
Fix mac errors
GuillaumeGomez Feb 4, 2020
ceae8b3
Update benchmark results for macos
GuillaumeGomez Feb 4, 2020
0a639fd
Add missing parts for unknown targets
GuillaumeGomez Feb 4, 2020
1021355
small cleanup
GuillaumeGomez Feb 4, 2020
1cc6b88
Implement IntoIterator on Networks
GuillaumeGomez Feb 4, 2020
a9e2eb9
Improve doc examples with removal of .iter() call
GuillaumeGomez Feb 4, 2020
9c6e411
Update linux benchmarks results
GuillaumeGomez Feb 4, 2020
f91999f
Don't read network compressed packets on linux for the moment
GuillaumeGomez Feb 4, 2020
83f86a7
Update linux benchmarks
GuillaumeGomez Feb 4, 2020
cd68da3
Update C interface
GuillaumeGomez Feb 5, 2020
aadbd04
Merge pull request #245 from GuillaumeGomez/nrc-vendor-up
GuillaumeGomez Feb 5, 2020
01eaae2
Extend NetworkExt interface
GuillaumeGomez Feb 5, 2020
331206d
Extend mac network interface
GuillaumeGomez Feb 5, 2020
004db8c
Extend linux network interface
GuillaumeGomez Feb 5, 2020
a0cb41b
Extend windows network interface
GuillaumeGomez Feb 5, 2020
ea66e31
Extend unknown network interface
GuillaumeGomez Feb 5, 2020
a96b020
fmt
GuillaumeGomez Feb 5, 2020
0de0180
Merge pull request #250 from GuillaumeGomez/extend-network
GuillaumeGomez Feb 5, 2020
b7ec800
Clippy fixes
GuillaumeGomez Feb 5, 2020
50cd57c
Merge pull request #251 from GuillaumeGomez/clippy
GuillaumeGomez Feb 5, 2020
144db82
clippy fixes on mac
GuillaumeGomez Feb 5, 2020
8acf8b3
Add clippy check on windows
GuillaumeGomez Feb 5, 2020
7cdbef5
Fix clippy errors on windows
GuillaumeGomez Feb 5, 2020
63460de
fmt
GuillaumeGomez Feb 5, 2020
aec0748
Merge pull request #253 from GuillaumeGomez/more-clippy
GuillaumeGomez Feb 6, 2020
06eba86
Add missing links inside documentation
GuillaumeGomez Feb 6, 2020
b1be538
Move DiskType enum to common file
GuillaumeGomez Feb 6, 2020
d35b4b1
Give more control over disks
GuillaumeGomez Feb 6, 2020
292fd03
Update components API to give more controlto the users
GuillaumeGomez Feb 6, 2020
1735697
fix windows errors
GuillaumeGomez Feb 6, 2020
2c2d581
Update benchmarks
GuillaumeGomez Feb 6, 2020
a40fa49
update linux benchmark results
GuillaumeGomez Feb 6, 2020
e83e622
Check for dead links as well
GuillaumeGomez Feb 6, 2020
e85b184
Update benchmark results for macOS
GuillaumeGomez Feb 6, 2020
b4fc323
Update windows benchmark results
GuillaumeGomez Feb 6, 2020
84ce867
Merge pull request #254 from GuillaumeGomez/more-control
GuillaumeGomez Feb 6, 2020
d2b41c1
Rename get_processor_list into get_processors
GuillaumeGomez Feb 7, 2020
71e0477
Update processor API
GuillaumeGomez Feb 7, 2020
ec2d72f
Add test to ensure that processor list is always set when initializin…
GuillaumeGomez Feb 7, 2020
aa55099
Ensure that System::new doesn't generate Process list
GuillaumeGomez Feb 7, 2020
08ce43f
Fix cpu computation
GuillaumeGomez Feb 7, 2020
756cdb5
get_cpu_usage now returns a value between 0 and 100
GuillaumeGomez Feb 7, 2020
518abbe
fmt
GuillaumeGomez Feb 7, 2020
7024672
Fix CPU usage computation on mac
GuillaumeGomez Feb 8, 2020
6931572
remove warning
GuillaumeGomez Feb 8, 2020
e3b21da
Update example
GuillaumeGomez Feb 8, 2020
15893ee
Improve documentation
GuillaumeGomez Feb 8, 2020
b32e4f3
Rename get_process_list into get_processes
GuillaumeGomez Feb 8, 2020
e9a74d8
Merge pull request #255 from GuillaumeGomez/processor
GuillaumeGomez Feb 8, 2020
6c4472d
Add tests for network
GuillaumeGomez Feb 8, 2020
3568540
cleanup
GuillaumeGomez Feb 8, 2020
47592c6
Upgrade crate version
GuillaumeGomez Feb 8, 2020
0f9ed16
Improve crate's description
GuillaumeGomez Feb 8, 2020
9d652c8
Merge pull request #256 from GuillaumeGomez/final-step
GuillaumeGomez Feb 8, 2020
3def3db
Error with network TX on linux
ClementTsang Feb 10, 2020
b723dcf
Merge pull request #258 from ClementTsang/master
GuillaumeGomez Feb 10, 2020
d99e542
Update crate version
GuillaumeGomez Feb 10, 2020
2828318
Merge pull request #259 from GuillaumeGomez/new-version
GuillaumeGomez Feb 10, 2020
87bab73
Document how to cross compile with proper Cargo configuration
momobel Feb 10, 2020
d7bfc1e
Merge pull request #260 from momobel/cross_compile
GuillaumeGomez Feb 10, 2020
7e6410b
Enforce SystemExt::refresh_process working the same on windows
GuillaumeGomez Feb 10, 2020
924f34d
Add tests to be sure that SystemExt::refresh_process adds the process…
GuillaumeGomez Feb 10, 2020
bf7b46b
fmt
GuillaumeGomez Feb 10, 2020
e874022
Merge pull request #262 from GuillaumeGomez/enforce-refresh-process
GuillaumeGomez Feb 10, 2020
1c72997
Fix ProcessExt::kill on windows
GuillaumeGomez Feb 10, 2020
56ad266
Improve ProcessExt::kill code on windows
GuillaumeGomez Feb 11, 2020
0319d16
Merge pull request #263 from GuillaumeGomez/windows-kill
GuillaumeGomez Feb 11, 2020
f86c614
Update crate version to 0.11.2
GuillaumeGomez Feb 11, 2020
5650b89
Merge pull request #264 from GuillaumeGomez/up-crate
GuillaumeGomez Feb 11, 2020
137790e
add functions get_cpu_frequency/get_avg_load
lonng Dec 3, 2019
faa68e6
support retrieve system wide configuration list
lonng Dec 3, 2019
ecd97b0
wrap num_cpus/pnet_datalink/cache_size crates
lonng Dec 4, 2019
424a36c
support retrieve network statistics
lonng Dec 3, 2019
eefc23a
support retrieve block device IO statistics
lonng Dec 3, 2019
2e70ddd
Remove unnecessary code
nrc Feb 15, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# These are supported funding model platforms

github: [GuillaumeGomez]
patreon: GuillaumeGomez
custom: ["https://paypal.me/imperioland"]
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ script:
- rustc --version
- sysctl -a | grep mem
- if [[ "$TRAVIS_RUST_VERSION" == "nightly" ]]; then
(rustup component add clippy-preview && cargo clippy) || touch clippy_install_failed;
(rustup component add clippy && cargo clippy) || touch clippy_install_failed;
fi
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
cargo build --features debug;
Expand All @@ -74,6 +74,7 @@ script:
- if [[ -z "$EXTRA" ]]; then
RUST_BACKTRACE=1 cargo test;
fi
- cargo doc
- cd examples
- if [[ -z "$EXTRA" ]]; then
RUST_BACKTRACE=1 cargo build;
Expand All @@ -87,4 +88,4 @@ script:
fi
- if [[ -z "$EXTRA" ]]; then
LD_LIBRARY_PATH=./target/debug ./simple;
fi
fi
14 changes: 10 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[package]
name = "sysinfo"
version = "0.9.6"
version = "0.11.2"
authors = ["Guillaume Gomez <[email protected]>"]

description = "Library to handle processes"
description = "Library to get system information such as processes, processors, disks, components and networks"
repository = "https://github.com/GuillaumeGomez/sysinfo"
license = "MIT"
readme = "README.md"
Expand All @@ -16,11 +16,17 @@ build = "build.rs"
cfg-if = "0.1"
rayon = "^1.0"
doc-comment = "0.3"
once_cell = "1.0"
walkdir = "2.2.9"
pnet_datalink = "0.23.0"
num_cpus = "1.11.1"
cache-size = "0.4.0"

[target.'cfg(windows)'.dependencies]
winapi = { version = "0.3", features = ["fileapi", "handleapi", "ioapiset", "minwindef", "pdh", "psapi", "synchapi", "sysinfoapi", "tlhelp32", "winbase", "winerror", "winioctl", "winnt"] }
winapi = { version = "0.3", features = ["fileapi", "handleapi", "ifdef", "ioapiset", "minwindef", "pdh", "psapi", "synchapi", "sysinfoapi", "winbase", "winerror", "winioctl", "winnt", "oleauto", "wbemcli", "rpcdce", "combaseapi", "objidl", "objbase", "powerbase", "netioapi"] }
ntapi = "0.3"

[target.'cfg(not(target_os = "unknown"))'.dependencies]
[target.'cfg(not(any(target_os = "unknown", target_arch = "wasm32")))'.dependencies]
libc = "0.2"

[lib]
Expand Down
106 changes: 97 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,28 @@ Support the following platforms:

* Linux
* Raspberry
* Mac OSX
* Android
* macOS
* Windows

It also compiles for Android but never been tested on it.

### Running on Raspberry

It'll be difficult to build on Raspberry. A good way-around is to be build on Linux before sending it to your Raspberry:
It'll be difficult to build on Raspberry. A good way-around is to be build on Linux before sending it to your Raspberry.

First install the arm toolchain, for example on Ubuntu: `sudo apt-get install gcc-multilib-arm-linux-gnueabihf`.

Then configure cargo to use the corresponding toolchain:

```bash
cat << EOF > ~/.cargo/config
[target.armv7-unknown-linux-gnueabihf]
linker = "arm-linux-gnueabihf-gcc"
EOF
```

Finally, cross compile:

```bash
rustup target add armv7-unknown-linux-gnueabihf
Expand All @@ -33,8 +47,6 @@ cargo build --target=armv7-unknown-linux-gnueabihf
You have an example into the `examples` folder. Just run `cargo run` inside the `examples` folder to start it. Otherwise, here is a little code sample:

```rust
extern crate sysinfo;

use sysinfo::{NetworkExt, System, SystemExt};

let mut sys = System::new();
Expand All @@ -55,13 +67,13 @@ for component in sys.get_components_list() {
}

// Memory information:
println!("total memory: {} kB", sys.get_total_memory());
println!("used memory : {} kB", sys.get_used_memory());
println!("total swap : {} kB", sys.get_total_swap());
println!("used swap : {} kB", sys.get_used_swap());
println!("total memory: {} KiB", sys.get_total_memory());
println!("used memory : {} KiB", sys.get_used_memory());
println!("total swap : {} KiB", sys.get_total_swap());
println!("used swap : {} KiB", sys.get_used_swap());

// Number of processors
println!("NB processors: {}", sys.get_processor_list().len());
println!("NB processors: {}", sys.get_processors().len());

// To refresh all system information:
sys.refresh_all();
Expand All @@ -80,6 +92,82 @@ To build the C example, just run:
> LD_LIBRARY_PATH=target/release/ ./simple
```

### Benchmarks

You can run the benchmarks locally with rust **nightly** by doing:

```bash
> cargo bench
```

Here are the current results:

**Linux**

<details>

```text
test bench_new ... bench: 3,741 ns/iter (+/- 252)
test bench_new_all ... bench: 10,491,084 ns/iter (+/- 450,925)
test bench_refresh_all ... bench: 2,787,974 ns/iter (+/- 235,649)
test bench_refresh_components ... bench: 24,270 ns/iter (+/- 1,127)
test bench_refresh_components_list ... bench: 370,693 ns/iter (+/- 51,925)
test bench_refresh_cpu ... bench: 13,367 ns/iter (+/- 1,858)
test bench_refresh_disks ... bench: 2,532 ns/iter (+/- 108)
test bench_refresh_disks_lists ... bench: 50,359 ns/iter (+/- 5,877)
test bench_refresh_memory ... bench: 11,713 ns/iter (+/- 1,006)
test bench_refresh_networks ... bench: 220,246 ns/iter (+/- 24,294)
test bench_refresh_networks_list ... bench: 229,648 ns/iter (+/- 82,050)
test bench_refresh_process ... bench: 77,375 ns/iter (+/- 10,657)
test bench_refresh_processes ... bench: 2,282,106 ns/iter (+/- 154,098)
test bench_refresh_system ... bench: 52,466 ns/iter (+/- 4,710)
```
</details>

**Windows**

<details>

```text
test bench_new ... bench: 7,688,460 ns/iter (+/- 1,230,010)
test bench_new_all ... bench: 24,098,860 ns/iter (+/- 5,260,950)
test bench_refresh_all ... bench: 3,096,107 ns/iter (+/- 94,257)
test bench_refresh_components ... bench: 1,205,378 ns/iter (+/- 40,071)
test bench_refresh_components_list ... bench: 3,181,602 ns/iter (+/- 102,533)
test bench_refresh_cpu ... bench: 395 ns/iter (+/- 18)
test bench_refresh_disks ... bench: 53,082 ns/iter (+/- 1,834)
test bench_refresh_disks_lists ... bench: 114,080 ns/iter (+/- 1,920)
test bench_refresh_memory ... bench: 596 ns/iter (+/- 48)
test bench_refresh_networks ... bench: 37,549 ns/iter (+/- 1,622)
test bench_refresh_networks_list ... bench: 667,180 ns/iter (+/- 59,859)
test bench_refresh_process ... bench: 755 ns/iter (+/- 47)
test bench_refresh_processes ... bench: 1,217,488 ns/iter (+/- 69,041)
test bench_refresh_system ... bench: 1,214,780 ns/iter (+/- 52,013)
```
</details>

**macOS**

<details>

```text
test bench_new ... bench: 56,861 ns/iter (+/- 5,653)
test bench_new_all ... bench: 4,634,509 ns/iter (+/- 1,604,369)
test bench_refresh_all ... bench: 1,962,343 ns/iter (+/- 129,726)
test bench_refresh_components ... bench: 294,752 ns/iter (+/- 45,107)
test bench_refresh_components_list ... bench: 895,672 ns/iter (+/- 112,586)
test bench_refresh_cpu ... bench: 11,187 ns/iter (+/- 2,483)
test bench_refresh_disks ... bench: 975 ns/iter (+/- 50)
test bench_refresh_disks_lists ... bench: 25,955 ns/iter (+/- 3,159)
test bench_refresh_memory ... bench: 3,440 ns/iter (+/- 198)
test bench_refresh_networks ... bench: 211,552 ns/iter (+/- 16,686)
test bench_refresh_networks_list ... bench: 211,138 ns/iter (+/- 22,644)
test bench_refresh_process ... bench: 4,174 ns/iter (+/- 1,249)
test bench_refresh_processes ... bench: 803,559 ns/iter (+/- 42,974)
test bench_refresh_system ... bench: 365,762 ns/iter (+/- 55,893)
```
</details>

## Donations

If you appreciate my work and want to support me, you can do it here:
Expand Down
3 changes: 3 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ install:
- curl -sSf -o rustup-init.exe https://win.rustup.rs
- rustup-init.exe --default-host "%ARCH%-pc-windows-gnu" --default-toolchain %RUST% -y
- SET PATH=C:\Users\appveyor\.cargo\bin;C:\msys64\mingw%BITS%\bin;%PATH%;C:\msys64\usr\bin
- rustup component add clippy
- rustc -Vv
- cargo -Vv

build_script:
- cargo clippy
- cargo build
- cargo test
- cargo doc
- cd examples
- cargo build

Expand Down
71 changes: 63 additions & 8 deletions benches/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
extern crate sysinfo;
extern crate test;

use sysinfo::get_current_pid;
use sysinfo::SystemExt;

#[bench]
Expand All @@ -12,9 +13,16 @@ fn bench_new(b: &mut test::Bencher) {
});
}

#[bench]
fn bench_new_all(b: &mut test::Bencher) {
b.iter(|| {
sysinfo::System::new_all();
});
}

#[bench]
fn bench_refresh_all(b: &mut test::Bencher) {
let mut s = sysinfo::System::new();
let mut s = sysinfo::System::new_all();

b.iter(move || {
s.refresh_all();
Expand All @@ -23,7 +31,7 @@ fn bench_refresh_all(b: &mut test::Bencher) {

#[bench]
fn bench_refresh_system(b: &mut test::Bencher) {
let mut s = sysinfo::System::new();
let mut s = sysinfo::System::new_all();

s.refresh_system();
b.iter(move || {
Expand All @@ -35,6 +43,7 @@ fn bench_refresh_system(b: &mut test::Bencher) {
fn bench_refresh_processes(b: &mut test::Bencher) {
let mut s = sysinfo::System::new();

s.refresh_processes(); // to load the whole processes list a first time.
b.iter(move || {
s.refresh_processes();
});
Expand All @@ -45,35 +54,81 @@ fn bench_refresh_process(b: &mut test::Bencher) {
let mut s = sysinfo::System::new();

s.refresh_all();
let pid = *s.get_process_list().iter().take(1).next().unwrap().0;
// to be sure it'll exist for at least as long as we run
let pid = get_current_pid().expect("failed to get current pid");
b.iter(move || {
s.refresh_process(pid);
});
}

#[bench]
fn bench_refresh_disks(b: &mut test::Bencher) {
let mut s = sysinfo::System::new();
let mut s = sysinfo::System::new_all();

b.iter(move || {
s.refresh_disks();
});
}

#[bench]
fn bench_refresh_disk_lists(b: &mut test::Bencher) {
fn bench_refresh_disks_lists(b: &mut test::Bencher) {
let mut s = sysinfo::System::new();

b.iter(move || {
s.refresh_disks_list();
});
}

#[bench]
fn bench_refresh_networks(b: &mut test::Bencher) {
let mut s = sysinfo::System::new_all();

b.iter(move || {
s.refresh_networks();
});
}

#[bench]
fn bench_refresh_networks_list(b: &mut test::Bencher) {
let mut s = sysinfo::System::new();

b.iter(move || {
s.refresh_networks_list();
});
}

#[bench]
fn bench_refresh_memory(b: &mut test::Bencher) {
let mut s = sysinfo::System::new();

b.iter(move || {
s.refresh_disk_list();
s.refresh_memory();
});
}

#[bench]
fn bench_refresh_network(b: &mut test::Bencher) {
fn bench_refresh_cpu(b: &mut test::Bencher) {
let mut s = sysinfo::System::new();

b.iter(move || {
s.refresh_network();
s.refresh_cpu();
});
}

#[bench]
fn bench_refresh_components(b: &mut test::Bencher) {
let mut s = sysinfo::System::new_all();

b.iter(move || {
s.refresh_components();
});
}

#[bench]
fn bench_refresh_components_list(b: &mut test::Bencher) {
let mut s = sysinfo::System::new_all();

b.iter(move || {
s.refresh_components_list();
});
}
18 changes: 9 additions & 9 deletions examples/src/simple.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,19 @@ bool process_loop(pid_t pid, CProcess process, void *data) {
int main() {
CSystem system = sysinfo_init();
sysinfo_refresh_all(system);
printf("total memory: %ld\n", sysinfo_get_total_memory(system));
printf("free memory: %ld\n", sysinfo_get_free_memory(system));
printf("used memory: %ld\n", sysinfo_get_used_memory(system));
printf("total swap: %ld\n", sysinfo_get_total_swap(system));
printf("free swap: %ld\n", sysinfo_get_free_swap(system));
printf("used swap: %ld\n", sysinfo_get_used_swap(system));
printf("network income: %ld\n", sysinfo_get_network_income(system));
printf("network outcome: %ld\n", sysinfo_get_network_outcome(system));
printf("total memory: %ld\n", sysinfo_get_total_memory(system));
printf("free memory: %ld\n", sysinfo_get_free_memory(system));
printf("used memory: %ld\n", sysinfo_get_used_memory(system));
printf("total swap: %ld\n", sysinfo_get_total_swap(system));
printf("free swap: %ld\n", sysinfo_get_free_swap(system));
printf("used swap: %ld\n", sysinfo_get_used_swap(system));
printf("networks income: %ld\n", sysinfo_get_networks_income(system));
printf("networks outcome: %ld\n", sysinfo_get_networks_outcome(system));
unsigned int len = 0, i = 0;
float *procs = NULL;
sysinfo_get_processors_usage(system, &len, &procs);
while (i < len) {
printf("Processor #%d usage: %f\n", i, procs[i]);
printf("Processor #%d usage: %f%%\n", i, procs[i]);
i += 1;
}
free(procs);
Expand Down
Loading