- array_push: documentation ( source)
- microtime: documentation ( source)
- hash_hmac: documentation ( source)
- round: documentation ( source)
- memory_get_usage: documentation ( source)
- rand: documentation ( source)
- sprintf: documentation ( source)
<?php
class Region
{
protected $city;
protected $country;
protected $cityCode;
protected $countryCode;
/**
* @return mixed
*/
public function getCity()
{
return $this->city;
}
/**
* @param mixed $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* @return mixed
*/
public function getCountry()
{
return $this->country;
}
/**
* @param mixed $country
*/
public function setCountry($country)
{
$this->country = $country;
}
/**
* @return mixed
*/
public function getCityCode()
{
return $this->cityCode;
}
/**
* @param mixed $cityCode
*/
public function setCityCode($cityCode)
{
$this->cityCode = $cityCode;
}
/**
* @return mixed
*/
public function getCountryCode()
{
return $this->countryCode;
}
/**
* @param mixed $countryCode
*/
public function setCountryCode($countryCode)
{
$this->countryCode = $countryCode;
}
}
$time = microtime(true);
$memory = memory_get_usage(true);
$collection = [];
$randSrtring = hash_hmac('md5',rand(0, 1000), 'some key');
for ($i = 0; $i <= 100000; $i++) {
$region = [];
$region['city'] = $randSrtring;
$region['city_code'] = $randSrtring;
$region['country'] = $randSrtring;
$region['country_code'] = $randSrtring;
array_push($collection, $region);
}
$resultTime = @(microtime(true) - $time);
$resultMemory = @round((memory_get_usage(true) - $memory) / (1024 * 1024));
echo sprintf(
"Time: %s, Memory: %sMB",
$resultTime,
$resultMemory
);