mirror of
https://github.com/mrclay/minify.git
synced 2025-08-27 15:50:15 +02:00
+ memcached test (buggy on Windows at least)
all min_extras apps use the cache path and lib location specified in min/config.php
This commit is contained in:
@@ -4,7 +4,7 @@ require '../../config.php';
|
||||
|
||||
require 'Minify.php';
|
||||
|
||||
// give an explicit path to avoid having to load Solar/Dir.php
|
||||
// set in /min/config.php
|
||||
Minify::setCache($minifyCachePath);
|
||||
|
||||
Minify::serve('Files', array(
|
||||
|
@@ -6,9 +6,25 @@ require 'Minify.php';
|
||||
require 'Minify/Cache/Memcache.php';
|
||||
|
||||
$mc = new Memcache;
|
||||
if (! $mc->connect('localhost', 11211)) {
|
||||
if (! @$mc->connect('localhost', 11211)) {
|
||||
file_put_contents(
|
||||
dirname(__FILE__) . '/../memcached_stats.txt'
|
||||
,"\nFailed connection.\n"
|
||||
,FILE_APPEND
|
||||
);
|
||||
die();
|
||||
}
|
||||
|
||||
if (0 == rand(0, 19)) {
|
||||
$stats = $mc->getStats();
|
||||
file_put_contents(
|
||||
dirname(__FILE__) . '/../memcached_stats.txt'
|
||||
,$stats['curr_connections'] . "\n"
|
||||
,FILE_APPEND
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Minify::setCache(new Minify_Cache_Memcache($mc));
|
||||
|
||||
Minify::serve('Files', array(
|
||||
|
@@ -4,7 +4,7 @@ require '../../config.php';
|
||||
|
||||
require 'Minify.php';
|
||||
|
||||
// give an explicit path to avoid having to load Solar/Dir.php
|
||||
// set in /min/config.php
|
||||
Minify::setCache($minifyCachePath);
|
||||
|
||||
Minify::serve('Groups', array(
|
||||
|
@@ -5,6 +5,7 @@ require '../../config.php';
|
||||
define('MINIFY_BASE_DIR', realpath(
|
||||
dirname(__FILE__) . '/../minify'
|
||||
));
|
||||
// set in /min/config.php
|
||||
define('MINIFY_CACHE_DIR', $minifyCachePath);
|
||||
|
||||
require 'Minify.php';
|
||||
|
19
min_extras/ab_tests/minify/test_memcache.php
Normal file
19
min_extras/ab_tests/minify/test_memcache.php
Normal file
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
$mc = new Memcache;
|
||||
if (! @$mc->connect('localhost', 11211)) {
|
||||
file_put_contents(
|
||||
dirname(__FILE__) . '/../memcached_stats.txt'
|
||||
,"Fail\n"
|
||||
,FILE_APPEND | LOCK_EX
|
||||
);
|
||||
die();
|
||||
}
|
||||
|
||||
$stats = $mc->getStats();
|
||||
file_put_contents(
|
||||
dirname(__FILE__) . '/../memcached_stats.txt'
|
||||
,$stats['curr_connections'] . "\n"
|
||||
,FILE_APPEND | LOCK_EX
|
||||
);
|
||||
|
@@ -1,13 +1,13 @@
|
||||
@SET PATH=%PATH%;C:\xampp\apache\bin
|
||||
@SET PATH=%PATH%;C:\xampp\apache\bin;C:\Program Files\GnuWin32\bin
|
||||
|
||||
@SET DOMAIN=http://mc.dev
|
||||
@SET DOMAIN=http://localhost/minify
|
||||
|
||||
@SET ABTESTS=%DOMAIN%/min_extras/ab_tests
|
||||
|
||||
ab -d -S -c 1 -n 2 -H "Accept-Encoding: deflate, gzip" %ABTESTS%/minify/test_Files_Memcache.php
|
||||
|
||||
DEL results.txt
|
||||
|
||||
ab -d -S -c 100 -n 1000 -H "Accept-Encoding: deflate, gzip" %ABTESTS%/minify/test_Files_Memcache.php >> results.txt
|
||||
DEL memcached_stats.txt
|
||||
|
||||
START "C:\Program Files\Notepad++\notepad++.exe" results.txt
|
||||
ab -d -S -c 100 -n 1000 %ABTESTS%/minify/test_memcache.php >> results.txt
|
||||
|
||||
START "C:\Program Files\Notepad++\notepad++.exe" memcached_stats.txt
|
@@ -1,17 +1,15 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Add the location of Minify's "lib" directory to the include_path. In
|
||||
* production this could be done via .htaccess or some other method.
|
||||
*/
|
||||
ini_set('include_path',
|
||||
dirname(__FILE__) . '/../min/lib'
|
||||
. PATH_SEPARATOR . ini_get('include_path')
|
||||
);
|
||||
// using same lib path and cache path specified in /min/config.php
|
||||
|
||||
/**
|
||||
* Set $minifyCachePath to a PHP-writeable path to enable server-side caching
|
||||
* in all examples and tests.
|
||||
*/
|
||||
$minifyCachePath = '';
|
||||
require dirname(__FILE__) . '/../min/config.php';
|
||||
|
||||
if (!isset($min_libPath)) {
|
||||
// default lib path is inside min
|
||||
$min_libPath = dirname(__FILE__) . '/../min/lib';
|
||||
}
|
||||
set_include_path($min_libPath . PATH_SEPARATOR . get_include_path());
|
||||
|
||||
$minifyCachePath = isset($min_cachePath)
|
||||
? $min_cachePath
|
||||
: '';
|
||||
|
@@ -2,7 +2,9 @@
|
||||
|
||||
if (isset($_FILES['subject']['name'])) {
|
||||
|
||||
require '../../min/lib/HTTP/Encoder.php';
|
||||
require '../config.php';
|
||||
|
||||
require 'HTTP/Encoder.php';
|
||||
$he = new HTTP_Encoder(array(
|
||||
'content' => file_get_contents($_FILES['subject']['tmp_name'])
|
||||
,'method' => $_POST['method']
|
||||
|
@@ -3,12 +3,9 @@
|
||||
if (isset($_FILES['subject']['name'])
|
||||
&& preg_match('/\\.(js|css|x?html?)$/', $_FILES['subject']['name'], $m)
|
||||
) {
|
||||
ini_set('include_path',
|
||||
dirname(__FILE__) . '/../../min/lib'
|
||||
. PATH_SEPARATOR . ini_get('include_path')
|
||||
);
|
||||
require '../config.php';
|
||||
|
||||
// eh why not
|
||||
// easier to just require them all
|
||||
require 'Minify/HTML.php';
|
||||
require 'Minify/CSS.php';
|
||||
require 'Minify/Javascript.php';
|
||||
|
Reference in New Issue
Block a user