Report memory usage
This commit is contained in:
parent
77a955c25e
commit
995a4228c9
@ -19,6 +19,11 @@
|
||||
* @link https://docs.madelineproto.xyz MadelineProto documentation
|
||||
*/
|
||||
|
||||
|
||||
if (function_exists('memprof_enable')) {
|
||||
memprof_enable();
|
||||
}
|
||||
|
||||
use Amp\Http\Server\HttpServer;
|
||||
use danog\MadelineProto\API;
|
||||
use danog\MadelineProto\APIWrapper;
|
||||
@ -86,6 +91,10 @@ class MyEventHandler extends \danog\MadelineProto\EventHandler
|
||||
$this->UPLOAD = \class_exists(HttpServer::class);
|
||||
parent::__construct($API);
|
||||
}
|
||||
public function onStart()
|
||||
{
|
||||
$this->adminId = yield $this->getInfo(self::ADMIN)['bot_api_id'];
|
||||
}
|
||||
/**
|
||||
* Handle updates from channels and supergroups.
|
||||
*
|
||||
@ -126,6 +135,13 @@ class MyEventHandler extends \danog\MadelineProto\EventHandler
|
||||
if ($update['message']['message'] === '/start') {
|
||||
return $this->messages->sendMessage(['peer' => $peerId, 'message' => self::START, 'parse_mode' => 'Markdown', 'reply_to_msg_id' => $messageId]);
|
||||
}
|
||||
if ($update['message']['message'] === '/report' && $peerId === $this->adminId) {
|
||||
memprof_dump_callgrind($stm = fopen("php://memory", "w"));
|
||||
fseek($stm, 0);
|
||||
yield $this->messages->sendMedia(['peer' => $peerId, 'media' => ['_' => 'inputMediaUploadedDocument', 'file' => $stm, 'attributes' => [['_' => 'documentAttributeFilename', 'file_name' => 'callgrind.out']]]]);
|
||||
fclose($stm);
|
||||
return;
|
||||
}
|
||||
if (isset($update['message']['media']['_']) && $update['message']['media']['_'] !== 'messageMediaWebPage') {
|
||||
if ($this->UPLOAD && ($this->states[$peerId] ?? false) === $this->UPLOAD) {
|
||||
unset($this->states[$peerId]);
|
||||
|
@ -110,7 +110,8 @@ trait AuthKeyHandler
|
||||
* ***********************************************************************
|
||||
* Compute p and q
|
||||
*/
|
||||
$pq = (string) new BigInteger((string) $pq_bytes, 256);
|
||||
$pq = new BigInteger((string) $pq_bytes, 256);
|
||||
$pqStr = (string) $pq;
|
||||
foreach ([
|
||||
'auto_single',
|
||||
'native_single_cpp',
|
||||
@ -124,9 +125,9 @@ trait AuthKeyHandler
|
||||
$q = new BigInteger(0);
|
||||
try {
|
||||
if ($method === 'wolfram') {
|
||||
$p = new BigInteger(yield from $this->wolframSingle($pq));
|
||||
$p = new BigInteger(yield from $this->wolframSingle($pqStr));
|
||||
} else {
|
||||
$p = new BigInteger(@PrimeModule::$method($pq));
|
||||
$p = new BigInteger(@PrimeModule::$method($pqStr));
|
||||
}
|
||||
} catch (\Throwable $e) {
|
||||
$this->logger->logger("While factorizing with $method: $e");
|
||||
|
Loading…
Reference in New Issue
Block a user