Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/Result.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
class Result
{
const MICRO_FORMAT = 'd-m-Y H:i:s.u';
/**
* Identifier given to the import/export
*
Expand Down Expand Up @@ -143,4 +144,18 @@ public function getExceptions()
{
return $this->exceptions;
}

/**
* find the elapsed microseconds for the result. This only finds the microsecond difference, use {@link getElapsed()}
*
* @return number
*/
public function getMicroElapsed()
{
$microStart = $this->startTime->format('u');
$microEnd = $this->endTime->format('u');
$microDiff = abs($microEnd - $microStart);

return $microDiff;
}
}
10 changes: 5 additions & 5 deletions src/Workflow/StepAggregator.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function __construct(Reader $reader, $name = null)
/**
* Add a step to the current workflow
*
* @param Step $step
* @param Step $step
* @param integer|null $priority
*
* @return $this
Expand Down Expand Up @@ -107,9 +107,9 @@ public function addWriter(Writer $writer)
*/
public function process()
{
$count = 0;
$count = 0;
$exceptions = new \SplObjectStorage();
$startTime = new \DateTime;
$startTime = new \DateTime(date_format(new \DateTime(), 'd-m-Y H:i:s') . substr((string)microtime(), 1, 8));

foreach ($this->writers as $writer) {
$writer->prepare();
Expand Down Expand Up @@ -145,7 +145,7 @@ public function process()
foreach ($this->writers as $writer) {
$writer->writeItem($item);
}
} catch(Exception $e) {
} catch (Exception $e) {
if (!$this->skipItemOnFailure) {
throw $e;
}
Expand All @@ -161,7 +161,7 @@ public function process()
$writer->finish();
}

return new Result($this->name, $startTime, new \DateTime, $count, $exceptions);
return new Result($this->name, $startTime, new \DateTime(date_format(new \DateTime(), 'd-m-Y H:i:s') . substr((string)microtime(), 1, 8)), $count, $exceptions);
}

/**
Expand Down
10 changes: 10 additions & 0 deletions tests/ResultTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,16 @@ public function testDates()
$this->assertInstanceOf('DateInterval', $result->getElapsed());
}

public function testMicroElapsed()
{
$startDate = new \DateTime('2016-07-12 20:51:42.805421');
$endDate = new \DateTime('2016-07-12 20:51:42.841276');
$microElapsed = abs($endDate->format('u') - $startDate->format('u'));

$result = new Result('export', $startDate, $endDate, 10, new \SplObjectStorage());
$this->assertSame($microElapsed, $result->getMicroElapsed());
}

public function testHasErrorsReturnsTrueIfAnyExceptions()
{
$exceptions = new \SplObjectStorage();
Expand Down