Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F154665
futures.php
No One
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Authored By
epriestley
May 14 2014, 1:58 PM
2014-05-14 13:58:08 (UTC+0)
Size
817 B
Referenced Files
None
Subscribers
None
futures.php
View Options
#!/usr/bin/env php
<?php
$root
=
dirname
(
dirname
(
dirname
(
__FILE__
)));
require_once
$root
.
'/scripts/__init_script__.php'
;
$number_of_tasks
=
$argv
[
1
];
$seconds_per_task
=
$argv
[
2
];
$seconds_of_processing
=
$argv
[
3
];
$futures
=
array
();
for
(
$ii
=
0
;
$ii
<
$number_of_tasks
;
$ii
++)
{
$futures
[]
=
new
ExecFuture
(
'sleep %d'
,
$seconds_per_task
);
}
echo
"[T = "
.
t
().
"] Starting {$number_of_tasks} tasks, "
.
"which will take {$seconds_per_task} each, "
.
"and require {$seconds_of_processing} seconds to process.
\n
"
;
foreach
(
Futures
(
$futures
)
as
$future
)
{
sleep
(
$seconds_of_processing
);
echo
"[T = "
.
t
().
"] Completed a task.
\n
"
;
}
echo
"[T = "
.
t
().
"] Done.
\n
"
;
function
t
()
{
static
$start
;
if
(!
$start
)
{
$start
=
microtime
(
true
);
}
return
sprintf
(
'%.1f'
,
microtime
(
true
)
-
$start
);
}
File Metadata
Details
Attached
Mime Type
text/plain; charset=utf-8
Storage Engine
amazon-s3
Storage Format
Raw Data
Storage Handle
phabricator/hn/on/5omlyesnf7lehp6u
Default Alt Text
futures.php (817 B)
Attached To
Mode
P1137 futures.php
Attached
Detach File
Event Timeline
Log In to Comment