-
-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Description
File size: 106.38 MB, Time: 00:00.175, Memory: 333.17 MB
<?php
declare(strict_types=1);
use SebastianBergmann\Timer\ResourceUsageFormatter;
use SebastianBergmann\Timer\Timer;
require __DIR__.'/vendor/autoload.php';
$timer = new Timer;
$timer->start();
$resourceRead = fopen($file = '/.../laravel-2024-09-12.log', 'rb');
$resourceWrite = fopen('/.../laravel-2024-09-12_copy.log', 'wb');
Clue\StreamFilter\append($resourceWrite, strtoupper(...));
// stream_filter_append($resourceWrite, 'string.toupper');
stream_copy_to_stream($resourceRead, $resourceWrite);
echo sprintf('File size: %.2f MB, ',
filesize($file) / 1024 / 1024), (new ResourceUsageFormatter)->resourceUsage($timer->stop());
// Output:
// File size: 106.38 MB, Time: 00:00.175, Memory: 333.17 MBFile size: 106.38 MB, Time: 00:00.089, Memory: 120.39 MB(using string.toupper)
<?php
declare(strict_types=1);
use SebastianBergmann\Timer\ResourceUsageFormatter;
use SebastianBergmann\Timer\Timer;
require __DIR__.'/vendor/autoload.php';
$timer = new Timer;
$timer->start();
$resourceRead = fopen($file = '/.../laravel-2024-09-12.log', 'rb');
$resourceWrite = fopen('/.../laravel-2024-09-12_copy.log', 'wb');
// Clue\StreamFilter\append($resourceWrite, strtoupper(...));
stream_filter_append($resourceWrite, 'string.toupper');
stream_copy_to_stream($resourceRead, $resourceWrite);
echo sprintf('File size: %.2f MB, ',
filesize($file) / 1024 / 1024), (new ResourceUsageFormatter)->resourceUsage($timer->stop());
// Output:
// File size: 106.38 MB, Time: 00:00.089, Memory: 120.39 MBMetadata
Metadata
Assignees
Labels
No labels