The settings will be read from the current folder, and the results written back out to it. So probably create an empty
folder to run it from.
1. Create a `settings.ini` file based off of the one included. Adjust workers/duration if desired. Configure your
database's connection information.
2. Create a generator file. This is just a plain PHP file that, at some point, `return`s a SQL query to run.
#### Examples
**settings.ini**
```
workers=16
duration=30
[db]
host=127.0.0.1
port=5432
username=postgres
password=postgres
database=my_database
```
**generator.php**
```
<?php
return "select * from my_table where id=".mt_rand(1, 65000);
```
### Run bench.php
Run the benchmarking tool.
```
$ php ~/path/to/bench.php
[Worker 0] Start
[Worker 1] Start
[Worker 2] Start
[Master] Start
[Worker 3] Start
[Worker 3] Stop
[Worker 1] Stop
[Worker 2] Stop
[Master] Stop
[Worker 0] Stop
$
```
Results are written to `worker.<number>.csv`. Each file will contain the query generated as well as the timing in
seconds.
### Analyze results
Run the results tool to aggregate all of the worker outputs.
```
$ php ~/path/to/results.php
5 percentile: 0.0417s
25 percentile: 0.042s
50 percentile: 0.0424s
75 percentile: 0.0431s
95 percentile: 0.0459s
99 percentile: 0.0505s
QPS: 93.6
```
You're done.
## License
```
Copyright (c) 2020 Adam Pippin. All rights reserved.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software must display the following acknowledgement:
This product includes software developed by Adam Pippin.
4. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.