Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit af4848f

Browse files
Added test xcache storage
Fixed running tests by name pattern
1 parent 4b6fb20 commit af4848f

File tree

3 files changed

+89
-9
lines changed

3 files changed

+89
-9
lines changed

‎bench.php

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,16 @@
105105
if (file_exists('UUID.php') && PHP_VERSION >= '5.0.0') {
106106
@include_once("php-uuid.inc");
107107
}
108-
if (file_exists('kvstorage-mem.inc') && PHP_VERSION >= '5.0.0') {
108+
if ( PHP_VERSION >= '5.0.0') {
109+
110+
if (file_exists('kvstorage-mem.inc')) {
109111
@include_once("kv-memory.inc");
110112
}
113+
if (file_exists('kvstorage-xcache.inc') && extension_loaded('xCache')) {
114+
@include_once("kv-xcache.inc");
115+
}
116+
}// php>=5.0
117+
111118
if (extension_loaded('uuid')) {
112119
@include_once("mod-uuid.inc");
113120
}
@@ -778,6 +785,7 @@ function gethostname() {
778785
'38_01_php_uuid' => 1000000,
779786
'38_02_mod_uuid' => 1000000,
780787
'39_01_kvstorage_memory' => 1000000,
788+
'39_02_kvstorage_xcache' => 1000000,
781789
);
782790
// Should not be more than X Mb
783791
// Different PHP could use different amount of memory
@@ -837,6 +845,7 @@ function gethostname() {
837845
'38_01_php_uuid' => 4,
838846
'38_02_mod_uuid' => 4,
839847
'39_01_kvstorage_memory' => 4,
848+
'39_02_kvstorage_xcache' => 4,
840849
);
841850

842851
/** ---------------------------------- Common functions -------------------------------------------- */
@@ -1522,18 +1531,18 @@ function format_result_test($diffSeconds, $opCount, $memory = 0)
15221531
// fiter in tests
15231532
function filter_in_name_by_pattern($key)
15241533
{
1525-
global $runTests, $debugMode, $availableFunctions;
1534+
global $selectedTests, $debugMode, $availableFunctions;
15261535
$var = $availableFunctions[$key];
15271536
$ret = 0;
1528-
foreach ($runTests as $pattern){
1537+
foreach ($selectedTests as $pattern){
15291538
// simple test - str in name
15301539
$c=strpos($var,$pattern);
15311540
if ($debugMode) {
15321541
$d=var_export($c,true);
15331542
print("Search '$pattern' inside '$var':$d\n");
15341543
}
15351544
if ($c!==false) {
1536-
$ret = 0;
1545+
$ret = 1;
15371546
break;
15381547
};
15391548
}
@@ -1565,7 +1574,7 @@ function filter_out_name_by_pattern($key)
15651574
if (!$ret) unset($availableFunctions[$key]);
15661575
return $ret;
15671576
}
1568-
if ($runTests) array_filter($availableFunctions, "filter_in_name_by_pattern",ARRAY_FILTER_USE_KEY);
1577+
if ($selectedTests) array_filter($availableFunctions, "filter_in_name_by_pattern",ARRAY_FILTER_USE_KEY);
15691578
if ($skipTests) array_filter($availableFunctions, "filter_out_name_by_pattern",ARRAY_FILTER_USE_KEY);
15701579
/** ------------------------------- Early checks ------------------------------- */
15711580

@@ -1617,7 +1626,7 @@ function filter_out_name_by_pattern($key)
16171626
$has_json = "{$colorRed}no{$colorReset}";
16181627
if ($printJson) {
16191628
print_pre("{$colorRed}<<< ERROR >>>{$colorReset} Extension 'json' is mandatory for JSON output!");
1620-
print("\"messages_count\": {$messagesCnt},\n");
1629+
print("\"messag0es_count\": {$messagesCnt},\n");
16211630
print("\"end\":true\n}" . PHP_EOL);
16221631
exit(-1);
16231632
}
@@ -1631,7 +1640,7 @@ function filter_out_name_by_pattern($key)
16311640
if (extension_loaded('Zend OPcache')) {
16321641
$has_opcache = "{$colorYellow}yes{$colorReset}";
16331642
}
1634-
$has_xcache = "{$colorGreen}no{$colorReset}";
1643+
$has_xcache = "{$colorYellow}no{$colorReset}";
16351644
if (extension_loaded('XCache')) {
16361645
$has_xcache = "{$colorYellow}yes{$colorReset}";
16371646
}
@@ -1814,11 +1823,11 @@ function print_results_common()
18141823
foreach ($availableFunctions as $user) {
18151824
if (strpos($user, 'test_') === 0) {
18161825
$testName = str_replace('test_', '', $user);
1817-
if ($runOnlySelectedTests) {
1826+
/*if ($runOnlySelectedTests) {
18181827
if (!in_array($testName, $selectedTests)) {
18191828
continue;
18201829
}
1821-
}
1830+
}*/
18221831
echo str_pad($testName, $padLabel) . " :";
18231832
list($resultSec, $resultSecFmt, $resultOps, $resultOpMhz, $memory) = $user();
18241833
$total += $resultSec;

‎kv-xcache.inc

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
<?php
2+
/**
3+
* php safe options - only tests array/class interfaces
4+
* Php 5.0+
5+
*/
6+
7+
/** ---------------------------------- Tests functions -------------------------------------------- */
8+
9+
// ------------------------- INTL tests -----------------------
10+
11+
/**
12+
* @since 5.0
13+
*/
14+
function test_39_02_kvstorage_xcache()
15+
{
16+
global $testsLoopLimits, $totalOps, $emptyResult;
17+
18+
if (!is_file('kvstorage-xcache.inc')){
19+
return $emptyResult;
20+
}
21+
22+
include_once('kvstorage-xcache.inc');
23+
if (!$kvstorage->available){
24+
return $emptyResult;
25+
}
26+
27+
$count = $testsLoopLimits['39_02_kvstorage_xcache'];
28+
$time_start = get_microtime();
29+
30+
for ($i = 0; $i < $count; $i++) {
31+
$num = $i / 100.;
32+
$kvstorage->set($i, $num);
33+
$v=$kvstorage->get($i);
34+
if ($v===$num) $kvstorage->del($i);
35+
}
36+
$totalOps += $count;
37+
return format_result_test(get_microtime() - $time_start, $count, mymemory_usage());
38+
}

‎kvstorage-xcache.inc

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
/**
3+
* Php 5.2+
4+
*/
5+
6+
class KVStorageXcache
7+
{
8+
public $available = false;
9+
public function __construct(){
10+
$this->available=true;
11+
if (!function_exists('xcache_set'))
12+
$this->available=false;
13+
if (!function_exists('xcache_get'))
14+
$this->available=false;
15+
if (!function_exists('xcache_unset'))
16+
$this->available=false;
17+
}
18+
19+
public function set($key, $value, $timeout=60){
20+
return xcache_set($key, $value);
21+
}
22+
23+
public function get($key, $default=null){
24+
return xcache_isset($key)
25+
? xcache_get($key)
26+
: $default;
27+
}
28+
29+
public function del($key){
30+
return xcache_unset($key);
31+
}
32+
}
33+
$kvstorage=new KVStorageXcache();

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /