mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-08 12:48:32 +00:00
Added bandwidth usage measurement to Window Status
This commit is contained in:
parent
6563169527
commit
c8e157156e
@ -94,9 +94,11 @@ class PocketMinecraftServer{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function titleTick(){
|
public function titleTick(){
|
||||||
|
$time = microtime(true);
|
||||||
if(ENABLE_ANSI === true){
|
if(ENABLE_ANSI === true){
|
||||||
echo "\x1b]0;PocketMine-MP ".MAJOR_VERSION." | Online ". count($this->clients)."/".$this->maxClients." | RAM ".round((memory_get_usage() / 1024) / 1024, 2)."MB | TPS ".$this->getTPS()."\x07";
|
echo "\x1b]0;PocketMine-MP ".MAJOR_VERSION." | Online ". count($this->clients)."/".$this->maxClients." | RAM ".round((memory_get_usage() / 1024) / 1024, 2)."MB | U ".round(($this->interface->bandwidth[0] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2)." D ".round(($this->interface->bandwidth[1] / max(1, $time - $this->interface->bandwidth[2])) / 1024, 2)." kB/s | TPS ".$this->getTPS()."\x07";
|
||||||
}
|
}
|
||||||
|
$this->interface->bandwidth = array(0, 0, $time);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function loadEvents(){
|
public function loadEvents(){
|
||||||
|
@ -27,6 +27,7 @@ the Free Software Foundation, either version 3 of the License, or
|
|||||||
|
|
||||||
class MinecraftInterface{
|
class MinecraftInterface{
|
||||||
public $client;
|
public $client;
|
||||||
|
public $bandwidth;
|
||||||
private $socket;
|
private $socket;
|
||||||
private $data;
|
private $data;
|
||||||
private $chunked;
|
private $chunked;
|
||||||
@ -38,6 +39,7 @@ class MinecraftInterface{
|
|||||||
console("[ERROR] Couldn't bind to $serverip:".$port, true, true, 0);
|
console("[ERROR] Couldn't bind to $serverip:".$port, true, true, 0);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
$this->bandwidth = array(0, 0, microtime(true));
|
||||||
$this->client = (bool) $client;
|
$this->client = (bool) $client;
|
||||||
$this->start = microtime(true);
|
$this->start = microtime(true);
|
||||||
$this->chunked = array();
|
$this->chunked = array();
|
||||||
@ -69,6 +71,7 @@ class MinecraftInterface{
|
|||||||
if($len === false){
|
if($len === false){
|
||||||
return $pk;
|
return $pk;
|
||||||
}
|
}
|
||||||
|
$this->bandwidth[0] += $len;
|
||||||
$this->parsePacket($buf, $source, $port);
|
$this->parsePacket($buf, $source, $port);
|
||||||
return ($pk !== false ? $pk : $this->popPacket());
|
return ($pk !== false ? $pk : $this->popPacket());
|
||||||
}
|
}
|
||||||
@ -244,6 +247,7 @@ class MinecraftInterface{
|
|||||||
$write = strlen($packet->raw);
|
$write = strlen($packet->raw);
|
||||||
}else{
|
}else{
|
||||||
$write = $this->socket->write($packet->raw, $dest, $port);
|
$write = $this->socket->write($packet->raw, $dest, $port);
|
||||||
|
$this->bandwidth[1] += $write;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if($force === false and $this->isChunked($CID)){
|
if($force === false and $this->isChunked($CID)){
|
||||||
@ -254,6 +258,7 @@ class MinecraftInterface{
|
|||||||
$write = strlen($data);
|
$write = strlen($data);
|
||||||
}else{
|
}else{
|
||||||
$write = $this->socket->write($data, $dest, $port);
|
$write = $this->socket->write($data, $dest, $port);
|
||||||
|
$this->bandwidth[1] += $write;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $write;
|
return $write;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user