-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from SimonFrings/documentation
Update documentation and examples to match version in early access
- Loading branch information
Showing
7 changed files
with
462 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/composer.lock | ||
/vendor/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
// To run the example, execute the following command: | ||
// $ php examples/91-benchmark-count.php < examples/users.tsv | ||
// | ||
// If you want to achieve more convincing result, | ||
// you can run the same example with some larger TSV files. | ||
// Take a look at: | ||
// @link https://datasets.imdbws.com/ | ||
|
||
use React\EventLoop\Loop; | ||
|
||
require __DIR__ . '/../vendor/autoload.php'; | ||
|
||
if (extension_loaded('xdebug')) { | ||
echo 'NOTICE: The "xdebug" extension is loaded, this has a major impact on performance.' . PHP_EOL; | ||
} | ||
|
||
$decoder = new Clue\React\Tsv\TsvDecoder(new React\Stream\ReadableResourceStream(STDIN)); | ||
|
||
$count = 0; | ||
$decoder->on('data', function () use (&$count) { | ||
++$count; | ||
}); | ||
|
||
$start = microtime(true); | ||
$report = Loop::addPeriodicTimer(0.05, function () use (&$count, $start) { | ||
printf("\r%d records in %0.3fs...", $count, microtime(true) - $start); | ||
}); | ||
|
||
$decoder->on('close', function () use (&$count, $report, $start) { | ||
$now = microtime(true); | ||
Loop::cancelTimer($report); | ||
|
||
printf("\r%d records in %0.3fs => %d records/s\n", $count, $now - $start, $count / ($now - $start)); | ||
}); |
Oops, something went wrong.