44
55namespace Keboola \Db \ImportExport \Backend ;
66
7- use Keboola \Db \Import \Result ;
8- use Tracy \Debugger ;
7+ use Symfony \Component \Stopwatch \Stopwatch ;
98
109class ImportState
1110{
@@ -24,19 +23,25 @@ class ImportState
2423 /** @var string */
2524 private $ stagingTableName = '' ;
2625
26+ /**
27+ * @var Stopwatch
28+ */
29+ private $ stopwatch ;
30+
2731 public function __construct (string $ stagingTableName )
2832 {
2933 $ this ->stagingTableName = $ stagingTableName ;
34+ $ this ->stopwatch = new Stopwatch ();
3035 }
3136
3237 public function addImportedRowsCount (int $ count ): void
3338 {
3439 $ this ->importedRowsCount += $ count ;
3540 }
3641
37- public function getResult (): Result
42+ public function getResult (): ImportResult
3843 {
39- return new Result ([
44+ return new ImportResult ([
4045 'warnings ' => $ this ->warnings ,
4146 'timers ' => array_values ($ this ->timers ), // convert to indexed array
4247 'importedRowsCount ' => $ this ->importedRowsCount ,
@@ -56,7 +61,7 @@ public function setImportedColumns(array $importedColumns): void
5661
5762 public function startTimer (string $ timerName ): void
5863 {
59- Debugger:: timer ($ timerName );
64+ $ this -> stopwatch -> start ($ timerName );
6065 $ this ->timers [$ timerName ] = [
6166 'name ' => $ timerName ,
6267 'durationSeconds ' => null ,
@@ -65,6 +70,7 @@ public function startTimer(string $timerName): void
6570
6671 public function stopTimer (string $ timerName ): void
6772 {
68- $ this ->timers [$ timerName ]['durationSeconds ' ] = Debugger::timer ($ timerName );
73+ $ miliseconds = $ this ->stopwatch ->stop ($ timerName )->getDuration ();
74+ $ this ->timers [$ timerName ]['durationSeconds ' ] = $ miliseconds / 1000 ;
6975 }
7076}
0 commit comments