Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
skeeks-semenov committed Mar 18, 2024
1 parent 2a5efe0 commit 8456be6
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions src/console/controllers/SkeeksSuppliersController.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,23 @@ public function options($actionID)
]);
}

private $_base_memory_usage = 0;

/**
* @return string
*/
private function _memoryUsage()
{
return \Yii::$app->formatter->asShortSize(memory_get_usage() - $this->_base_memory_usage);
}

/**
* @return false|void
*/
public function init()
{
$this->_base_memory_usage = memory_get_usage();

if (!isset(\Yii::$app->skeeksSuppliersApi)) {
throw new Exception("Компонент skeeksSuppliersApi не подключен");
}
Expand Down Expand Up @@ -118,7 +130,7 @@ public function actionUpdateCountries()
{
$response = \Yii::$app->skeeksSuppliersApi->methodCountries();

$this->stdout("Обновление стран [{$response->time} сек]", Console::BG_BLUE);
$this->stdout("Обновление стран [{$response->time} сек] [{$this->_memoryUsage()}]", Console::BG_BLUE);
$this->stdout("\n");

$updated = 0;
Expand Down Expand Up @@ -193,7 +205,7 @@ public function actionUpdateMeasures()
{
$response = \Yii::$app->skeeksSuppliersApi->methodMeasures();

$this->stdout("Обновление едениц измерения [{$response->time} сек]", Console::BG_BLUE);
$this->stdout("Обновление едениц измерения [{$response->time} сек] [{$this->_memoryUsage()}]", Console::BG_BLUE);
$this->stdout("\n");

$updated = 0;
Expand Down Expand Up @@ -250,7 +262,7 @@ public function actionUpdateCategories($page = 1)
'page' => $page
]);

$this->stdout("Обновление категорий, страница {$page} [{$response->time} сек]", Console::BG_BLUE);
$this->stdout("Обновление категорий, страница {$page} [{$response->time} сек] [{$this->_memoryUsage()}]", Console::BG_BLUE);
$this->stdout("\n");

$total = $response->headers->get("x-pagination-total-count");
Expand Down Expand Up @@ -301,6 +313,7 @@ public function actionUpdateCategories($page = 1)
}

if ($page < $pageCount) {
unset($response);
$this->actionUpdateCategories($page + 1);
}
}
Expand All @@ -315,7 +328,7 @@ public function actionUpdateProperties($page = 1)
'page' => $page
]);

$this->stdout("Обновление характеристик, страница {$page} [{$response->time} сек]", Console::BG_BLUE);
$this->stdout("Обновление характеристик, страница {$page} [{$response->time} сек] [{$this->_memoryUsage()}]", Console::BG_BLUE);
$this->stdout("\n");

$total = $response->headers->get("x-pagination-total-count");
Expand Down Expand Up @@ -364,6 +377,7 @@ public function actionUpdateProperties($page = 1)
}

if ($page < $pageCount) {
unset($response);
$this->actionUpdateProperties($page + 1);
}
}
Expand All @@ -378,7 +392,7 @@ public function actionUpdateBrands($page = 1)
'page' => $page
]);

$this->stdout("Обновление брендов, страница {$page} [{$response->time} сек]", Console::BG_BLUE);
$this->stdout("Обновление брендов, страница {$page} [{$response->time} сек] [{$this->_memoryUsage()}]", Console::BG_BLUE);
$this->stdout("\n");

$total = $response->headers->get("x-pagination-total-count");
Expand Down Expand Up @@ -427,6 +441,7 @@ public function actionUpdateBrands($page = 1)
}

if ($page < $pageCount) {
unset($response);
$this->actionUpdateBrands($page + 1);
}
}
Expand All @@ -442,7 +457,7 @@ public function actionUpdateCollections($page = 1)
'page' => $page
]);

$this->stdout("Обновление коллекций, страница {$page} [{$response->time} сек]", Console::BG_BLUE);
$this->stdout("Обновление коллекций, страница {$page} [{$response->time} сек] [{$this->_memoryUsage()}]", Console::BG_BLUE);
$this->stdout("\n");

$total = $response->headers->get("x-pagination-total-count");
Expand Down Expand Up @@ -491,6 +506,7 @@ public function actionUpdateCollections($page = 1)
}

if ($page < $pageCount) {
unset($response);
$this->actionUpdateCollections($page + 1);
}
}
Expand All @@ -505,7 +521,7 @@ public function actionUpdateStores($page = 1)
'page' => $page
]);

$this->stdout("Обновление складов, страница {$page} [{$response->time} сек]", Console::BG_BLUE);
$this->stdout("Обновление складов, страница {$page} [{$response->time} сек] [{$this->_memoryUsage()}]", Console::BG_BLUE);
$this->stdout("\n");

$total = $response->headers->get("x-pagination-total-count");
Expand Down Expand Up @@ -555,6 +571,7 @@ public function actionUpdateStores($page = 1)
}

if ($page < $pageCount) {
unset($response);
$this->actionUpdateStores($page + 1);
}
}
Expand Down Expand Up @@ -590,7 +607,7 @@ public function actionUpdateProducts($is_new = 1, $page = 1)

$response = \Yii::$app->skeeksSuppliersApi->methodProducts($apiQuery);

$this->stdout("Обновление товаров, страница {$page} [{$response->time} сек]", Console::BG_BLUE);
$this->stdout("Обновление товаров, страница {$page} [{$response->time} сек] [{$this->_memoryUsage()}]", Console::BG_BLUE);
$this->stdout("\n");

$total = $response->headers->get("x-pagination-total-count");
Expand Down Expand Up @@ -643,6 +660,7 @@ public function actionUpdateProducts($is_new = 1, $page = 1)
}

if ($page < $pageCount) {
unset($response);
$this->actionUpdateProducts($is_new, $page + 1);
}
}
Expand Down

0 comments on commit 8456be6

Please sign in to comment.