Skip to content

Commit

Permalink
Improve docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
daylerees committed Feb 5, 2016
1 parent 1b65d49 commit 0c9b86e
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changelog

- Will be maintained after alpha releases are out of the way. :)
65 changes: 64 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,66 @@
# Contribution Guide

Is coming soon!
This guide will be updated with more thorough content, but for now, the best thing you could do to help the project is to create `Journal` packages.

Journals are used to export the information from experiments to data stores for later inspection. They implement the `Scientist\Journals\Journal` interface:

```php
<?php

namespace Scientist\Journals;

use Scientist\Report;
use Scientist\Experiment;

/**
* Class Journal
*
* Journals allow the scientist to record experiment results in a
* variety of different ways.
*
* @package \Scientist
*/
interface Journal
{
/**
* Dispatch a report to storage.
*
* @param \Scientist\Experiment $experiment
* @param \Scientist\Report $report
*
* @return mixed
*/
public function report(Experiment $experiment, Report $report);
}

```

When you implement the `report()` method, the registered Journal will receive an instance of the experiment, and the report from the executed experiment. You can interrogate these instances for all kinds of useful information, and ship that information to a data storage platform.

Here's some useful methods:

```php
$report->getName(); // Get the experiment name. (string)
$report->getControl(); // Get the Scientist\Result instance for the control. (Scientist\Result)
$report->getTrial('name'); // Get the result instance for a trial by name. (Scientist\Result)
$report->getTrials(); // Get an assoc array of trial result instances (array)
```

And on the result instance:

```php
$result->getValue(); // Get the resulting value of the trial/control callback. (mixed)
$result->isMatch(); // Did the result match the control? Use on trial results. (boolean)
$result->getStartTime(); // Float callable start microtime. (float)
$result->getEndTime(); // Float callable end microtime. (float)
$result->getTime(); // Get the execution microtime. (float)
$result->getStartMemory(); // Get memory usage before calling. (integer)
$result->getEndMemory(); // Get memory usage after calling. (integer)
$result->getMemory(); // Get different in memory usage. (integer)
```

If you create a new journal (and a composer package, format scientist-xxx-journal) then please be sure to raise an issue and let me know! I'll update the docs to mentions it.

Thanks for all your support!

- Dayle.
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@ A PHP experiment library inspired by Github's own [Scientist](https://github.com

---

<div class="warning">
<h2>Alpha Version</h2>
<p>We're almost there, but please use caution for now. The API may change during alpha.</p>
</div>


## Installation

Expand Down Expand Up @@ -224,4 +229,10 @@ $value = $laboratory

## Additional Documentation

Is coming soon, along with a contribution guide.
Is coming soon.

Don't forget to check out the [contributors guide](CONTRIBUTING.md).

Thanks for checking out Scientist!

- Dayle.
2 changes: 1 addition & 1 deletion tests/ExperimentTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public function test_that_running_experiment_with_zero_chance_executes_control()
->control(function () { return 'foo'; })
->chance(0)
->run();

$this->assertEquals('foo', $v);
}
}

0 comments on commit 0c9b86e

Please sign in to comment.