Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Created by PhpStorm.
- * User: francesco
- * Date: 21/05/2018
- * Time: 22:42
- */
- $hit = 0;
- $limit = (int) drush_get_option("limit", 20);
- $attempts = (int) drush_get_option("attempts", 50000);
- if ($limit < 1 || $limit > 100) {
- echo "limit must be between 1 and 100\n";
- return;
- }
- echo "Attempts are $attempts\n";
- echo "Limit is $limit%\n";
- for ($i = 1; $i <= $attempts; $i++) {
- $hit = $hit + (rand(1, 100) <= $limit ? 1 : 0);
- echo $i . " attempts processed so far.... (temp hit ratio is " . ($hit / $i) * 100 . "%) \r";
- }
- echo "\n";
- echo "Final hit ratio is was " . ($hit / $attempts) * 100 . "%\n";
- /*
- OUTPUT IS SOMETHING SIMILAR TO THIS:
- Attempts are 100000
- Limit is 30%
- 100000 attempts processed so far.... (temp hit ratio is 30.258%)
- Final hit ratio is was 30.258%
- */
Add Comment
Please, Sign In to add comment