Skip to content

Commit

Permalink
Add editorconfig file and standardize on unix-style line endings.
Browse files Browse the repository at this point in the history
  • Loading branch information
bheisler committed Jan 14, 2018
1 parent c89d59d commit e0b6e21
Show file tree
Hide file tree
Showing 18 changed files with 1,066 additions and 1,058 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true

[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = space
98 changes: 49 additions & 49 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,50 @@
# 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).

## [Unreleased]

## [0.1.2]
### Changed
- Criterion.rs is now stable-compatible!
- Criterion.rs now includes its own stable-compatible `black_box` function.
Some benchmarks may now be affected by dead-code-elimination where they
previously weren't and may have to be updated.
- Criterion.rs now uses `serde` to save results. Existing results files will
be automatically removed when benchmarks are run.
- Redesigned the command-line output to highlight the important information
and reduce noise.

### Added
- Running benchmarks with the variable "CRITERION_DEBUG" in the environment will
cause Criterion.rs to generate extra debug output and save the gnuplot scripts
alongside the generated plots.

### Fixed
- Don't panic on IO errors or gnuplot failures
- Fix generation of invalid gnuplot scripts when benchmarking over inputs and inputs include values <= 0.
- Bug where benchmarks would run one sample fewer than was configured.

### Removed
- Generated plots will no longer use log-scale.

## [0.1.1]
### Added
- A changelog file.
- Added a chapter to the book on how Criterion.rs collects and analyzes data.
- Added macro rules to generate a test harness for use with `cargo bench`.
Benchmarks defined without these macros should continue to work.
- New contribution guidelines
- Criterion.rs can selectively run benchmarks. See the Command-line page for
more details

## 0.1.0 - 2017-12-02
### Added
- Initial release on Crates.io.


[Unreleased]: https://github.com/japaric/criterion.rs/compare/0.1.2...HEAD
[0.1.1]: https://github.com/japaric/criterion.rs/compare/0.1.0...0.1.1
# 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).

## [Unreleased]

## [0.1.2]
### Changed
- Criterion.rs is now stable-compatible!
- Criterion.rs now includes its own stable-compatible `black_box` function.
Some benchmarks may now be affected by dead-code-elimination where they
previously weren't and may have to be updated.
- Criterion.rs now uses `serde` to save results. Existing results files will
be automatically removed when benchmarks are run.
- Redesigned the command-line output to highlight the important information
and reduce noise.

### Added
- Running benchmarks with the variable "CRITERION_DEBUG" in the environment will
cause Criterion.rs to generate extra debug output and save the gnuplot scripts
alongside the generated plots.

### Fixed
- Don't panic on IO errors or gnuplot failures
- Fix generation of invalid gnuplot scripts when benchmarking over inputs and inputs include values <= 0.
- Bug where benchmarks would run one sample fewer than was configured.

### Removed
- Generated plots will no longer use log-scale.

## [0.1.1]
### Added
- A changelog file.
- Added a chapter to the book on how Criterion.rs collects and analyzes data.
- Added macro rules to generate a test harness for use with `cargo bench`.
Benchmarks defined without these macros should continue to work.
- New contribution guidelines
- Criterion.rs can selectively run benchmarks. See the Command-line page for
more details

## 0.1.0 - 2017-12-02
### Added
- Initial release on Crates.io.


[Unreleased]: https://github.com/japaric/criterion.rs/compare/0.1.2...HEAD
[0.1.1]: https://github.com/japaric/criterion.rs/compare/0.1.0...0.1.1
[0.1.2]: https://github.com/japaric/criterion.rs/compare/0.1.1...0.1.2
92 changes: 46 additions & 46 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
# Contributing to Criterion.<span></span>rs

## Ideas, Experiences and Questions

The easiest way to contribute to Criterion.<span></span>rs is to use it and report your experiences, ask questions and contribute ideas. We'd love to hear your thoughts on how to make Criterion.<span></span>rs better, or your comments on why you are or are not currently using it.

Issues, ideas, requests and questions should be posted on the issue tracker at:

https://github.com/japaric/criterion.rs/issues

## Code

Pull requests are welcome, though please raise an issue for discussion first if none exists. We're happy to assist new contributors.

If you're not sure what to work on, try checking the [good first issue label](https://github.com/japaric/criterion.rs/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)

To make changes to the code, fork the repo and clone it:

`git clone [email protected]:your-username/criterion.rs.git`

You'll probably want to install [gnuplot](http://www.gnuplot.info/) as well. See the gnuplot website for installation instructions.

Then make your changes to the code. When you're done, run the tests:

```
cargo test --all
cargo bench
```

It's a good idea to run clippy and fix any warnings as well:

```
cargo install clippy
cargo clippy --all
```

Don't forget to update the CHANGELOG.md file and any appropriate documentation. Once you're finished, push to your fork and submit a pull request. We try to respond to new issues and pull requests quickly, so if there hasn't been any response for more than a few days feel free to ping @bheisler.

Some things that will increase the chance that your pull request is accepted:

* Write tests
* Clearly document public methods
* Write a good commit message

## Code of Conduct

# Contributing to Criterion.<span></span>rs

## Ideas, Experiences and Questions

The easiest way to contribute to Criterion.<span></span>rs is to use it and report your experiences, ask questions and contribute ideas. We'd love to hear your thoughts on how to make Criterion.<span></span>rs better, or your comments on why you are or are not currently using it.

Issues, ideas, requests and questions should be posted on the issue tracker at:

https://github.com/japaric/criterion.rs/issues

## Code

Pull requests are welcome, though please raise an issue for discussion first if none exists. We're happy to assist new contributors.

If you're not sure what to work on, try checking the [good first issue label](https://github.com/japaric/criterion.rs/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)

To make changes to the code, fork the repo and clone it:

`git clone [email protected]:your-username/criterion.rs.git`

You'll probably want to install [gnuplot](http://www.gnuplot.info/) as well. See the gnuplot website for installation instructions.

Then make your changes to the code. When you're done, run the tests:

```
cargo test --all
cargo bench
```

It's a good idea to run clippy and fix any warnings as well:

```
cargo install clippy
cargo clippy --all
```

Don't forget to update the CHANGELOG.md file and any appropriate documentation. Once you're finished, push to your fork and submit a pull request. We try to respond to new issues and pull requests quickly, so if there hasn't been any response for more than a few days feel free to ping @bheisler.

Some things that will increase the chance that your pull request is accepted:

* Write tests
* Clearly document public methods
* Write a good commit message

## Code of Conduct

We follow the [Rust Code of Conduct](http://www.rust-lang.org/conduct.html).
40 changes: 20 additions & 20 deletions benches/bench_main.rs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
#[macro_use]
extern crate criterion;
extern crate walkdir;

mod no_plots;
mod compare_functions;
mod external_process;
mod iter_with_large_drop;
mod iter_with_large_setup;
mod iter_with_setup;
mod with_inputs;

criterion_main!{
no_plots::benches,
compare_functions::fibonaccis,
external_process::benches,
iter_with_large_drop::benches,
iter_with_large_setup::benches,
iter_with_setup::benches,
with_inputs::benches
#[macro_use]
extern crate criterion;
extern crate walkdir;

mod no_plots;
mod compare_functions;
mod external_process;
mod iter_with_large_drop;
mod iter_with_large_setup;
mod iter_with_setup;
mod with_inputs;

criterion_main!{
no_plots::benches,
compare_functions::fibonaccis,
external_process::benches,
iter_with_large_drop::benches,
iter_with_large_setup::benches,
iter_with_setup::benches,
with_inputs::benches
}
72 changes: 36 additions & 36 deletions benches/compare_functions.rs
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
use criterion::Criterion;
use criterion::Fun;

fn fibonacci_slow(n: u64) -> u64 {
match n {
0 | 1 => 1,
n => fibonacci_slow(n-1) + fibonacci_slow(n-2),
}
}

fn fibonacci_fast(n: u64) -> u64 {
let mut a = 0u64;
let mut b = 1u64;
let mut c : u64;

if n == 0 {
return 0
}

for _ in 0..(n+1) {
c = a + b;
a = b;
b = c;
}
b
}

fn compare_fibonaccis(c: &mut Criterion) {
let fib_slow = Fun::new("Recursive", |b, i| b.iter(|| fibonacci_slow(*i)));
let fib_fast = Fun::new("Iterative", |b, i| b.iter(|| fibonacci_fast(*i)));

let functions = vec!(fib_slow, fib_fast);

c.bench_functions("Fibonacci", functions, &20);
}

use criterion::Criterion;
use criterion::Fun;

fn fibonacci_slow(n: u64) -> u64 {
match n {
0 | 1 => 1,
n => fibonacci_slow(n-1) + fibonacci_slow(n-2),
}
}

fn fibonacci_fast(n: u64) -> u64 {
let mut a = 0u64;
let mut b = 1u64;
let mut c : u64;

if n == 0 {
return 0
}

for _ in 0..(n+1) {
c = a + b;
a = b;
b = c;
}
b
}

fn compare_fibonaccis(c: &mut Criterion) {
let fib_slow = Fun::new("Recursive", |b, i| b.iter(|| fibonacci_slow(*i)));
let fib_fast = Fun::new("Iterative", |b, i| b.iter(|| fibonacci_fast(*i)));

let functions = vec!(fib_slow, fib_fast);

c.bench_functions("Fibonacci", functions, &20);
}

criterion_group!(fibonaccis, compare_fibonaccis);
44 changes: 22 additions & 22 deletions benches/external_process.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
use criterion::Criterion;
use std::process::Command;
use std::process::Stdio;

fn create_command() -> Command {
let mut command = Command::new("python3");
command.arg("benches/external_process.py");
command
}

fn python_fibonacci(c: &mut Criterion) {
let has_python3 = Command::new("python3")
.arg("--version")
.stdout(Stdio::null())
.stderr(Stdio::null())
.output().is_ok();

if has_python3 {
c.bench_program("fibonacci-python", create_command());
}
}

use criterion::Criterion;
use std::process::Command;
use std::process::Stdio;

fn create_command() -> Command {
let mut command = Command::new("python3");
command.arg("benches/external_process.py");
command
}

fn python_fibonacci(c: &mut Criterion) {
let has_python3 = Command::new("python3")
.arg("--version")
.stdout(Stdio::null())
.stderr(Stdio::null())
.output().is_ok();

if has_python3 {
c.bench_program("fibonacci-python", create_command());
}
}

criterion_group!(benches, python_fibonacci);
Loading

0 comments on commit e0b6e21

Please sign in to comment.