benchs: limit algo columns in overall list + memcache

This commit is contained in:
Tanguy Pruvot 2017-07-25 09:28:14 +02:00
parent a7ff05d9a5
commit 38f70c6521
2 changed files with 53 additions and 29 deletions

View file

@ -15,51 +15,60 @@ class YaampMemcache
return memcache_get($this->memcache, $key);
}
public function set($key, $value, $t=30)
public function set($key, $value, $t=30, $options=0)
{
memcache_set($this->memcache, $key, $value, 0, $t);
memcache_set($this->memcache, $key, $value, $options, $t);
}
////////////////////////////////////////////////////////////////
public function get_database_count($key, $query, $params=array())
{
}
public function get_database_scalar($key, $query, $params=array())
public function get_database_scalar($key, $query, $params=array(), $t=30)
{
$value = $this->get($key);
if($value === false)
{
if($value === false) {
$value = dboscalar($query, $params);
$this->set($key, $value);
$this->set($key, $value, $t);
}
return $value;
}
public function get_database_count_ex($key, $table, $query, $params=array())
public function get_database_column($key, $query, $params=array(), $t=30)
{
$value = $this->get($key);
if($value === false)
{
if($value === false) {
$value = dbocolumn($query, $params);
$this->set($key, $value, $t);
}
return $value;
}
public function get_database_count_ex($key, $table, $query, $params=array(), $t=30)
{
$value = $this->get($key);
if($value === false) {
$value = getdbocount($table, $query, $params);
$this->set($key, $value);
$this->set($key, $value, $t);
}
return $value;
}
public function get_database_row($key, $query, $params=array())
public function get_database_list($key, $query, $params=array(), $t=30)
{
$value = $this->get($key);
if($value === false)
{
$value = dborow($query, $params);
$this->set($key, $value);
if($value === false) {
$value = dbolist($query, $params);
$this->set($key, $value, $t, MEMCACHE_COMPRESSED);
}
return $value;
}
public function get_database_row($key, $query, $params=array(), $t=30)
{
$value = $this->get($key);
if($value === false) {
$value = dborow($query, $params);
$this->set($key, $value, $t);
}
return $value;
}
@ -78,8 +87,6 @@ class YaampMemcache
$a[$name] = $count+1;
memcache_set($this->memcache, 'url-map', $a);
}
};
}

View file

@ -2,10 +2,21 @@
include('functions.php');
$client_ip = arraySafeVal($_SERVER,'REMOTE_ADDR');
$whitelisted = isAdminIP($client_ip);
if (!$whitelisted && is_file(YAAMP_LOGS.'/overloaded')) {
header('HTTP/1.0 503 Disabled, server overloaded');
return;
}
$this->pageTitle = "Devices";
$chips = array();
$in_db = dbolist("SELECT DISTINCT device, type, chip, idchip, vendorid FROM benchmarks WHERE idchip > 0 ORDER BY type DESC, device, vendorid");
// todo: bench_devices table to cache that
$in_db = $this->memcache->get_database_list("benchmarks-devices",
"SELECT DISTINCT device, type, chip, idchip, vendorid FROM benchmarks WHERE idchip > 0 ORDER BY type DESC, device, vendorid",
array(), 120
);
foreach ($in_db as $key => $row) {
$vendorid = $row['vendorid'];
$chip = $row['chip'];
@ -42,7 +53,12 @@ Devices in database
end;
$algos_columns = '';
$algos = dbocolumn("SELECT DISTINCT algo FROM benchmarks ORDER BY algo LIMIT 30");
$month = time() - (30 * 24 * 3600);
$algos = $this->memcache->get_database_column("benchmarks-algos",
"SELECT DISTINCT algo FROM benchmarks WHERE time > $month ORDER BY algo LIMIT 20",
array(), 120
);
foreach ($algos as $algo) {
$algos_columns .= '<th>'.$algo.'</th>';
}
@ -101,9 +117,10 @@ foreach ($in_db as $row) {
echo '<td>'.CHtml::link($row['vendorid'],'/bench?vid='.$row['vendorid']).'</td>';
if (!empty($vendorid))
$records = dbocolumn("SELECT algo FROM benchmarks WHERE vendorid=:vid ", array(':vid'=>$vendorid));
$records = dbocolumn("SELECT DISTINCT algo FROM benchmarks WHERE vendorid=:vid ", array(':vid'=>$vendorid));
else
$records = dbocolumn("SELECT algo FROM benchmarks WHERE device=:dev ", array(':dev'=>$row['device'])); // cpu
$records = dbocolumn("SELECT DISTINCT algo FROM benchmarks WHERE device=:dev ", array(':dev'=>$row['device'])); // cpu
foreach ($algos as $algo) {
$tick = '&nbsp;';
if (in_array($algo, $records)) {