-
Notifications
You must be signed in to change notification settings - Fork 115
Expand file tree
/
Copy pathcommon.php
More file actions
37 lines (32 loc) · 941 Bytes
/
common.php
File metadata and controls
37 lines (32 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
if (php_sapi_name() != 'cli') {
die('Must run from command line');
}
error_reporting(E_ALL);
ini_set('display_errors', 1);
ini_set('log_errors', 0);
ini_set('html_errors', 0);
foreach(array(__DIR__ . '/../vendor', __DIR__ . '/../../../../vendor') as $vendorDir) {
if(is_dir($vendorDir)) {
require_once $vendorDir . '/autoload.php';
break;
}
}
function test_notify(cli\Notify $notify, $cycle = 1000000, $sleep = null) {
for ($i = 0; $i < $cycle; $i++) {
$notify->tick();
if ($sleep) usleep($sleep);
}
$notify->finish();
}
function test_notify_msg(cli\Notify $notify, $cycle = 1000000, $sleep = null) {
$notify->display();
for ($i = 0; $i < $cycle; $i++) {
// Sleep before tick to simulate time-intensive work and give time
// for the initial message to display before it is changed
if ($sleep) usleep($sleep);
$msg = sprintf(' Finished step %d', $i + 1);
$notify->tick(1, $msg);
}
$notify->finish();
}