-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added execution time to pipeline report
- Loading branch information
1 parent
31e927e
commit 3dc9196
Showing
16 changed files
with
250 additions
and
30 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flow\Clock; | ||
|
||
use Psr\Clock\ClockInterface; | ||
|
||
final class FakeClock implements ClockInterface | ||
{ | ||
public function __construct(private \DateTimeImmutable $dateTime = new \DateTimeImmutable('now')) | ||
{ | ||
} | ||
|
||
public function modify(string $modify) : void | ||
{ | ||
$this->dateTime = $this->dateTime->modify($modify); | ||
} | ||
|
||
public function now() : \DateTimeImmutable | ||
{ | ||
return $this->dateTime; | ||
} | ||
|
||
public function set(\DateTimeImmutable $dateTime) : void | ||
{ | ||
$this->dateTime = $dateTime; | ||
} | ||
} |
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,29 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flow\Clock; | ||
|
||
use Psr\Clock\ClockInterface; | ||
|
||
final readonly class SystemClock implements ClockInterface | ||
{ | ||
public function __construct(private \DateTimeZone $timezone) | ||
{ | ||
} | ||
|
||
public static function system() : self | ||
{ | ||
return new self(new \DateTimeZone(date_default_timezone_get())); | ||
} | ||
|
||
public static function utc() : self | ||
{ | ||
return new self(new \DateTimeZone('UTC')); | ||
} | ||
|
||
public function now() : \DateTimeImmutable | ||
{ | ||
return new \DateTimeImmutable('now', $this->timezone); | ||
} | ||
} |
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
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
27 changes: 27 additions & 0 deletions
27
src/core/etl/src/Flow/ETL/Dataset/Statistics/ExecutionTime.php
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,27 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flow\ETL\Dataset\Statistics; | ||
|
||
use Flow\ETL\Exception\InvalidArgumentException; | ||
|
||
final readonly class ExecutionTime | ||
{ | ||
public function __construct(public \DateTimeImmutable $startedAt, public \DateTimeImmutable $finishedAt) | ||
{ | ||
if ($startedAt > $finishedAt) { | ||
throw new InvalidArgumentException('Execution start date must be before finish date'); | ||
} | ||
} | ||
|
||
public function duration() : \DateInterval | ||
{ | ||
return $this->startedAt->diff($this->finishedAt); | ||
} | ||
|
||
public function inSeconds() : int | ||
{ | ||
return $this->finishedAt->getTimestamp() - $this->startedAt->getTimestamp(); | ||
} | ||
} |
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,31 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Flow\Clock; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class SystemClockTest extends TestCase | ||
{ | ||
public function test_now() : void | ||
{ | ||
$clock = SystemClock::system(); | ||
|
||
self::assertInstanceOf(\DateTimeImmutable::class, $clock->now()); | ||
} | ||
|
||
public function test_system_clock() : void | ||
{ | ||
$clock = SystemClock::system(); | ||
|
||
self::assertInstanceOf(SystemClock::class, $clock); | ||
} | ||
|
||
public function test_utc_clock() : void | ||
{ | ||
$clock = SystemClock::utc(); | ||
|
||
self::assertInstanceOf(SystemClock::class, $clock); | ||
} | ||
} |
Oops, something went wrong.