mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Use now() helper for calculating scripts runtime
This commit is contained in:
@@ -168,7 +168,7 @@ class Backfill
|
||||
public function backfillGroup($groupArr, $left, $articles = ''): void
|
||||
{
|
||||
// Start time for this group.
|
||||
$startGroup = microtime(true);
|
||||
$startGroup = now()->timestamp;
|
||||
|
||||
$this->_binaries->logIndexerStart();
|
||||
|
||||
@@ -318,7 +318,7 @@ class Backfill
|
||||
'Group '.
|
||||
$groupName.
|
||||
' processed in '.
|
||||
number_format(microtime(true) - $startGroup, 2).
|
||||
number_format(now()->timestamp - $startGroup, 2).
|
||||
' seconds.'
|
||||
);
|
||||
}
|
||||
|
||||
+14
-14
@@ -281,7 +281,7 @@ class Binaries
|
||||
$groupCount = \count($groups);
|
||||
if ($groupCount > 0) {
|
||||
$counter = 1;
|
||||
$allTime = microtime(true);
|
||||
$allTime = now()->timestamp;
|
||||
|
||||
$this->log(
|
||||
'Updating: '.$groupCount.' group(s) - Using compression? '.($this->_compressedHeaders ? 'Yes' : 'No'),
|
||||
@@ -301,7 +301,7 @@ class Binaries
|
||||
}
|
||||
|
||||
$this->log(
|
||||
'Updating completed in '.number_format(microtime(true) - $allTime, 2).' seconds.',
|
||||
'Updating completed in '.number_format(now()->timestamp - $allTime, 2).' seconds.',
|
||||
__FUNCTION__,
|
||||
'primary'
|
||||
);
|
||||
@@ -334,7 +334,7 @@ class Binaries
|
||||
*/
|
||||
public function updateGroup($groupMySQL, $maxHeaders = 0): void
|
||||
{
|
||||
$startGroup = microtime(true);
|
||||
$startGroup = now()->timestamp;
|
||||
|
||||
$this->logIndexerStart();
|
||||
|
||||
@@ -541,7 +541,7 @@ class Binaries
|
||||
if ($this->_echoCLI) {
|
||||
$this->colorCli->primary(
|
||||
PHP_EOL.'Group '.$groupMySQL['name'].' processed in '.
|
||||
number_format(microtime(true) - $startGroup, 2).' seconds.'
|
||||
number_format(now()->timestamp - $startGroup, 2).' seconds.'
|
||||
);
|
||||
}
|
||||
} elseif ($this->_echoCLI) {
|
||||
@@ -570,7 +570,7 @@ class Binaries
|
||||
public function scan($groupMySQL, $first, $last, $type = 'update', $missingParts = null): array
|
||||
{
|
||||
// Start time of scan method and of fetching headers.
|
||||
$this->startLoop = microtime(true);
|
||||
$this->startLoop = now();
|
||||
$this->groupMySQL = $groupMySQL;
|
||||
$this->last = $last;
|
||||
$this->first = $first;
|
||||
@@ -642,10 +642,10 @@ class Binaries
|
||||
}
|
||||
|
||||
// Start of processing headers.
|
||||
$this->startCleaning = microtime(true);
|
||||
$this->startCleaning = now();
|
||||
|
||||
// End of the getting data from usenet.
|
||||
$this->timeHeaders = number_format($this->startCleaning - $this->startLoop, 2);
|
||||
$this->timeHeaders = $this->startCleaning->diffInSeconds($this->startLoop);
|
||||
|
||||
// Check if we got headers.
|
||||
$msgCount = \count($headers);
|
||||
@@ -742,10 +742,10 @@ class Binaries
|
||||
unset($stdHeaders);
|
||||
|
||||
// Start of part repair.
|
||||
$this->startPR = microtime(true);
|
||||
$this->startPR = now();
|
||||
|
||||
// End of inserting.
|
||||
$this->timeInsert = number_format($this->startPR - $this->startUpdate, 2);
|
||||
$this->timeInsert = $this->startPR->diffInSeconds($this->startUpdate);
|
||||
|
||||
if ($partRepair && \count($headersRepaired) > 0) {
|
||||
$this->removeRepairedParts($headersRepaired, $this->tableNames['prname'], $this->groupMySQL['id']);
|
||||
@@ -933,10 +933,10 @@ class Binaries
|
||||
//unset($headers); // Reclaim memory.
|
||||
|
||||
// Start of inserting into SQL.
|
||||
$this->startUpdate = microtime(true);
|
||||
$this->startUpdate = now();
|
||||
|
||||
// End of processing headers.
|
||||
$this->timeCleaning = number_format($this->startUpdate - $this->startCleaning, 2);
|
||||
$this->timeCleaning = $this->startUpdate->diffInSeconds($this->startCleaning);
|
||||
$binariesQuery = $binariesCheck = sprintf('INSERT INTO %s (id, partsize, currentparts) VALUES ', $this->tableNames['bname']);
|
||||
foreach ($binariesUpdate as $binaryID => $binary) {
|
||||
$binariesQuery .= '('.$binaryID.','.$binary['Size'].','.$binary['Parts'].'),';
|
||||
@@ -1023,7 +1023,7 @@ class Binaries
|
||||
*/
|
||||
protected function outputHeaderDuration(): void
|
||||
{
|
||||
$currentMicroTime = microtime(true);
|
||||
$currentMicroTime = now();
|
||||
if ($this->_echoCLI) {
|
||||
$this->colorCli->alternateOver($this->timeHeaders.'s').
|
||||
$this->colorCli->primaryOver(' to download articles, ').
|
||||
@@ -1031,9 +1031,9 @@ class Binaries
|
||||
$this->colorCli->primaryOver(' to process collections, ').
|
||||
$this->colorCli->alternateOver($this->timeInsert.'s').
|
||||
$this->colorCli->primaryOver(' to insert binaries/parts, ').
|
||||
$this->colorCli->alternateOver(number_format($currentMicroTime - $this->startPR, 2).'s').
|
||||
$this->colorCli->alternateOver($currentMicroTime->diffInSeconds($this->startPR).'s').
|
||||
$this->colorCli->primaryOver(' for part repair, ').
|
||||
$this->colorCli->alternateOver(number_format($currentMicroTime - $this->startLoop, 2).'s').
|
||||
$this->colorCli->alternateOver($currentMicroTime->diffInSeconds($this->startLoop).'s').
|
||||
$this->colorCli->primary(' total.');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -475,7 +475,7 @@ class Books
|
||||
|
||||
$bookId = -2;
|
||||
foreach ($res as $arr) {
|
||||
$startTime = microtime(true);
|
||||
$startTime = now()->timestamp;
|
||||
$usedAmazon = false;
|
||||
// audiobooks are also books and should be handled in an identical manor, even though it falls under a music category
|
||||
if ($arr['categories_id'] === '3030') {
|
||||
@@ -519,7 +519,7 @@ class Books
|
||||
}
|
||||
}
|
||||
// Sleep to not flood amazon.
|
||||
$diff = floor((microtime(true) - $startTime) * 1000000);
|
||||
$diff = floor((now()->timestamp - $startTime) * 1000000);
|
||||
if ($this->sleeptime * 1000 - $diff > 0 && $usedAmazon === true) {
|
||||
usleep($this->sleeptime * 1000 - $diff);
|
||||
}
|
||||
|
||||
@@ -925,7 +925,7 @@ class Console
|
||||
}
|
||||
|
||||
foreach ($res as $arr) {
|
||||
$startTime = microtime(true);
|
||||
$startTime = now()->timestamp;
|
||||
$usedAmazon = false;
|
||||
$gameId = self::CONS_NTFND;
|
||||
$gameInfo = $this->parseTitle($arr['searchname']);
|
||||
@@ -971,7 +971,7 @@ class Console
|
||||
Release::query()->where('id', $arr['id'])->update(['consoleinfo_id'=> $gameId]);
|
||||
|
||||
// Sleep to not flood amazon.
|
||||
$diff = floor((microtime(true) - $startTime) * 1000000);
|
||||
$diff = floor((now()->timestamp - $startTime) * 1000000);
|
||||
if ($this->sleeptime * 1000 - $diff > 0 && $usedAmazon === true) {
|
||||
usleep($this->sleeptime * 1000 - $diff);
|
||||
}
|
||||
|
||||
@@ -181,7 +181,7 @@ class Forking extends \fork_daemon
|
||||
public function processWorkType($type, array $options = [])
|
||||
{
|
||||
// Set/reset some variables.
|
||||
$startTime = microtime(true);
|
||||
$startTime = now()->timestamp;
|
||||
$this->workType = $type;
|
||||
$this->workTypeOptions = $options;
|
||||
$this->processAdditional = $this->processNFO = $this->processTV = $this->processMovies = $this->ppRenamedOnly = false;
|
||||
@@ -201,7 +201,7 @@ class Forking extends \fork_daemon
|
||||
|
||||
if (config('nntmux.echocli')) {
|
||||
$this->colorCli->header(
|
||||
'Multi-processing for '.$this->workType.' finished in '.(microtime(true) - $startTime).
|
||||
'Multi-processing for '.$this->workType.' finished in '.(now()->timestamp - $startTime).
|
||||
' seconds at '.date(DATE_RFC2822).'.'.PHP_EOL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ class ForkingImportNZB extends Forking
|
||||
*/
|
||||
public function start($folder, $maxProcesses, $deleteComplete, $deleteFailed, $useFileName, $maxPerProcess): void
|
||||
{
|
||||
$startTime = microtime(true);
|
||||
$startTime = now()->timestamp;
|
||||
$directories = glob($folder.'/*', GLOB_ONLYDIR);
|
||||
|
||||
$this->_workCount = \count($directories);
|
||||
@@ -85,7 +85,7 @@ class ForkingImportNZB extends Forking
|
||||
|
||||
if (config('nntmux.echocli')) {
|
||||
$this->colorCli->header(
|
||||
'Multi-processing for import finished in '.(microtime(true) - $startTime).
|
||||
'Multi-processing for import finished in '.(now()->timestamp - $startTime).
|
||||
' seconds at '.date(DATE_RFC2822).'.'.PHP_EOL
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
2018-11-29 DariusIII
|
||||
* Chg: Use now() helper for calculating scripts runtime
|
||||
* Chg: Simplify functions that check for mgrPoster variable
|
||||
* Chg: Update imdbphp/imdbphp to version 6.1.2
|
||||
* Chg: Use DB::statement in place of DB::unprepared + DB::commit
|
||||
|
||||
@@ -25,7 +25,7 @@ if ($res instanceof \Traversable) {
|
||||
$colorCli->header('Updating console info for '.number_format($res->rowCount()).' releases.');
|
||||
|
||||
foreach ($res as $arr) {
|
||||
$starttime = microtime(true);
|
||||
$starttime = now()->timestamp;
|
||||
$gameInfo = $console->parseTitle($arr['searchname']);
|
||||
if ($gameInfo !== false) {
|
||||
$game = $console->updateConsoleInfo($gameInfo);
|
||||
@@ -35,7 +35,7 @@ if ($res instanceof \Traversable) {
|
||||
}
|
||||
|
||||
// amazon limits are 1 per 1 sec
|
||||
$diff = floor((microtime(true) - $starttime) * 1000000);
|
||||
$diff = floor((now()->timestamp - $starttime) * 1000000);
|
||||
if (1000000 - $diff > 0) {
|
||||
$colorCli->alternate('Sleeping');
|
||||
usleep(1000000 - $diff);
|
||||
|
||||
@@ -19,7 +19,7 @@ if ($total > 0) {
|
||||
$colorCli->header('Updating game covers for '.number_format($total).' releases.');
|
||||
|
||||
foreach ($res as $arr) {
|
||||
$starttime = microtime(true);
|
||||
$starttime = now()->timestamp;
|
||||
$gameInfo = $game->parseTitle($arr['title']);
|
||||
if ($gameInfo !== false) {
|
||||
$colorCli->primary('Looking up: '.$gameInfo['release']);
|
||||
@@ -34,7 +34,7 @@ if ($total > 0) {
|
||||
}
|
||||
|
||||
// amazon limits are 1 per 1 sec
|
||||
$diff = floor((microtime(true) - $starttime) * 1000000);
|
||||
$diff = floor((now()->timestamp - $starttime) * 1000000);
|
||||
if (1000000 - $diff > 0) {
|
||||
$colorCli->alternate('Sleeping');
|
||||
usleep(1000000 - $diff);
|
||||
|
||||
@@ -18,11 +18,11 @@ if ($movies instanceof \Traversable) {
|
||||
$colorCli->header('Updating movie info for '.number_format($count).' movies.');
|
||||
|
||||
foreach ($movies as $mov) {
|
||||
$startTime = microtime(true);
|
||||
$startTime = now()->timestamp;
|
||||
$mov = $movie->updateMovieInfo($mov['imdbid']);
|
||||
|
||||
// tmdb limits are 30 per 10 sec, not certain for imdb
|
||||
$diff = floor((microtime(true) - $startTime) * 1000000);
|
||||
$diff = floor((now()->timestamp - $startTime) * 1000000);
|
||||
if (333333 - $diff > 0) {
|
||||
echo "sleeping\n";
|
||||
usleep(333333 - $diff);
|
||||
|
||||
@@ -15,7 +15,7 @@ $count = $movies->count();
|
||||
if ($count > 0) {
|
||||
$colorCli->primary('Updating '.number_format($count).' movie covers.');
|
||||
foreach ($movies as $mov) {
|
||||
$startTime = microtime(true);
|
||||
$startTime = now()->timestamp;
|
||||
$mov = $movie->updateMovieInfo($mov['imdbid']);
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -13,11 +13,11 @@ $movies = DB::select('SELECT title FROM xxxinfo WHERE cover = 0');
|
||||
|
||||
echo $c->primary('Updating '.number_format(\count($movies)).' XXX movie covers.');
|
||||
foreach ($movies as $mov) {
|
||||
$starttime = microtime(true);
|
||||
$starttime = now()->timestamp;
|
||||
$mov = $movie->updateXXXInfo($mov->title);
|
||||
|
||||
// sleep so that it's not ddos' the site
|
||||
$diff = floor((microtime(true) - $starttime) * 1000000);
|
||||
$diff = floor((now()->timestamp - $starttime) * 1000000);
|
||||
if (333333 - $diff > 0) {
|
||||
echo "\nsleeping\n";
|
||||
usleep(333333 - $diff);
|
||||
|
||||
Reference in New Issue
Block a user