@@ -66,11 +66,23 @@ public function options($actionID)
66
66
]);
67
67
}
68
68
69
+ private $ _base_memory_usage = 0 ;
70
+
71
+ /**
72
+ * @return string
73
+ */
74
+ private function _memoryUsage ()
75
+ {
76
+ return \Yii::$ app ->formatter ->asShortSize (memory_get_usage () - $ this ->_base_memory_usage );
77
+ }
78
+
69
79
/**
70
80
* @return false|void
71
81
*/
72
82
public function init ()
73
83
{
84
+ $ this ->_base_memory_usage = memory_get_usage ();
85
+
74
86
if (!isset (\Yii::$ app ->skeeksSuppliersApi )) {
75
87
throw new Exception ("Компонент skeeksSuppliersApi не подключен " );
76
88
}
@@ -118,7 +130,7 @@ public function actionUpdateCountries()
118
130
{
119
131
$ response = \Yii::$ app ->skeeksSuppliersApi ->methodCountries ();
120
132
121
- $ this ->stdout ("Обновление стран [ {$ response ->time } сек] " , Console::BG_BLUE );
133
+ $ this ->stdout ("Обновление стран [ {$ response ->time } сек] [ { $ this -> _memoryUsage ()} ] " , Console::BG_BLUE );
122
134
$ this ->stdout ("\n" );
123
135
124
136
$ updated = 0 ;
@@ -193,7 +205,7 @@ public function actionUpdateMeasures()
193
205
{
194
206
$ response = \Yii::$ app ->skeeksSuppliersApi ->methodMeasures ();
195
207
196
- $ this ->stdout ("Обновление едениц измерения [ {$ response ->time } сек] " , Console::BG_BLUE );
208
+ $ this ->stdout ("Обновление едениц измерения [ {$ response ->time } сек] [ { $ this -> _memoryUsage ()} ] " , Console::BG_BLUE );
197
209
$ this ->stdout ("\n" );
198
210
199
211
$ updated = 0 ;
@@ -250,7 +262,7 @@ public function actionUpdateCategories($page = 1)
250
262
'page ' => $ page
251
263
]);
252
264
253
- $ this ->stdout ("Обновление категорий, страница {$ page } [ {$ response ->time } сек] " , Console::BG_BLUE );
265
+ $ this ->stdout ("Обновление категорий, страница {$ page } [ {$ response ->time } сек] [ { $ this -> _memoryUsage ()} ] " , Console::BG_BLUE );
254
266
$ this ->stdout ("\n" );
255
267
256
268
$ total = $ response ->headers ->get ("x-pagination-total-count " );
@@ -301,6 +313,7 @@ public function actionUpdateCategories($page = 1)
301
313
}
302
314
303
315
if ($ page < $ pageCount ) {
316
+ unset($ response );
304
317
$ this ->actionUpdateCategories ($ page + 1 );
305
318
}
306
319
}
@@ -315,7 +328,7 @@ public function actionUpdateProperties($page = 1)
315
328
'page ' => $ page
316
329
]);
317
330
318
- $ this ->stdout ("Обновление характеристик, страница {$ page } [ {$ response ->time } сек] " , Console::BG_BLUE );
331
+ $ this ->stdout ("Обновление характеристик, страница {$ page } [ {$ response ->time } сек] [ { $ this -> _memoryUsage ()} ] " , Console::BG_BLUE );
319
332
$ this ->stdout ("\n" );
320
333
321
334
$ total = $ response ->headers ->get ("x-pagination-total-count " );
@@ -364,6 +377,7 @@ public function actionUpdateProperties($page = 1)
364
377
}
365
378
366
379
if ($ page < $ pageCount ) {
380
+ unset($ response );
367
381
$ this ->actionUpdateProperties ($ page + 1 );
368
382
}
369
383
}
@@ -378,7 +392,7 @@ public function actionUpdateBrands($page = 1)
378
392
'page ' => $ page
379
393
]);
380
394
381
- $ this ->stdout ("Обновление брендов, страница {$ page } [ {$ response ->time } сек] " , Console::BG_BLUE );
395
+ $ this ->stdout ("Обновление брендов, страница {$ page } [ {$ response ->time } сек] [ { $ this -> _memoryUsage ()} ] " , Console::BG_BLUE );
382
396
$ this ->stdout ("\n" );
383
397
384
398
$ total = $ response ->headers ->get ("x-pagination-total-count " );
@@ -427,6 +441,7 @@ public function actionUpdateBrands($page = 1)
427
441
}
428
442
429
443
if ($ page < $ pageCount ) {
444
+ unset($ response );
430
445
$ this ->actionUpdateBrands ($ page + 1 );
431
446
}
432
447
}
@@ -442,7 +457,7 @@ public function actionUpdateCollections($page = 1)
442
457
'page ' => $ page
443
458
]);
444
459
445
- $ this ->stdout ("Обновление коллекций, страница {$ page } [ {$ response ->time } сек] " , Console::BG_BLUE );
460
+ $ this ->stdout ("Обновление коллекций, страница {$ page } [ {$ response ->time } сек] [ { $ this -> _memoryUsage ()} ] " , Console::BG_BLUE );
446
461
$ this ->stdout ("\n" );
447
462
448
463
$ total = $ response ->headers ->get ("x-pagination-total-count " );
@@ -491,6 +506,7 @@ public function actionUpdateCollections($page = 1)
491
506
}
492
507
493
508
if ($ page < $ pageCount ) {
509
+ unset($ response );
494
510
$ this ->actionUpdateCollections ($ page + 1 );
495
511
}
496
512
}
@@ -505,7 +521,7 @@ public function actionUpdateStores($page = 1)
505
521
'page ' => $ page
506
522
]);
507
523
508
- $ this ->stdout ("Обновление складов, страница {$ page } [ {$ response ->time } сек] " , Console::BG_BLUE );
524
+ $ this ->stdout ("Обновление складов, страница {$ page } [ {$ response ->time } сек] [ { $ this -> _memoryUsage ()} ] " , Console::BG_BLUE );
509
525
$ this ->stdout ("\n" );
510
526
511
527
$ total = $ response ->headers ->get ("x-pagination-total-count " );
@@ -555,6 +571,7 @@ public function actionUpdateStores($page = 1)
555
571
}
556
572
557
573
if ($ page < $ pageCount ) {
574
+ unset($ response );
558
575
$ this ->actionUpdateStores ($ page + 1 );
559
576
}
560
577
}
@@ -590,7 +607,7 @@ public function actionUpdateProducts($is_new = 1, $page = 1)
590
607
591
608
$ response = \Yii::$ app ->skeeksSuppliersApi ->methodProducts ($ apiQuery );
592
609
593
- $ this ->stdout ("Обновление товаров, страница {$ page } [ {$ response ->time } сек] " , Console::BG_BLUE );
610
+ $ this ->stdout ("Обновление товаров, страница {$ page } [ {$ response ->time } сек] [ { $ this -> _memoryUsage ()} ] " , Console::BG_BLUE );
594
611
$ this ->stdout ("\n" );
595
612
596
613
$ total = $ response ->headers ->get ("x-pagination-total-count " );
@@ -643,6 +660,7 @@ public function actionUpdateProducts($is_new = 1, $page = 1)
643
660
}
644
661
645
662
if ($ page < $ pageCount ) {
663
+ unset($ response );
646
664
$ this ->actionUpdateProducts ($ is_new , $ page + 1 );
647
665
}
648
666
}
0 commit comments