1
0
mirror of https://github.com/mrclay/minify.git synced 2025-08-13 09:34:54 +02:00

ab_tests/ : + test for /min (and reran)

examples : cleanup
- examples/3
- jquery-1.2.3.js (unneeded duplicate)
This commit is contained in:
Steve Clay
2008-09-04 01:08:38 +00:00
parent f9378dc345
commit 4c9d62be82
14 changed files with 78 additions and 3529 deletions

View File

@@ -1,28 +1,38 @@
Document Path: /_3rd_party/minify/web/ab_tests/ideal_php/before.php
Document Path: /min_extras/ab_tests/ideal_php/before.php
Document Length: 15993 bytes
Requests per second: 429.53 [#/sec] (mean)
Requests per second: 415.58 [#/sec] (mean)
--------------------------------------------------------------------------------
Document Path: /_3rd_party/minify/web/ab_tests/v1.0/minify.php?files=before.js
Document Path: /min_extras/ab_tests/v1.0/minify.php?files=before.js
Document Length: 54159 bytes
Requests per second: 299.07 [#/sec] (mean)
Requests per second: 275.86 [#/sec] (mean)
--------------------------------------------------------------------------------
Document Path: /_3rd_party/minify/web/ab_tests/minify/test_Files.php
Document Path: /min_extras/ab_tests/minify/test_Files.php
Document Length: 15993 bytes
Requests per second: 243.81 [#/sec] (mean)
(Connect: 0, Length: 4, Exceptions: 0)
Requests per second: 239.70 [#/sec] (mean)
--------------------------------------------------------------------------------
Document Path: /_3rd_party/minify/web/ab_tests/minify/test_Groups.php/test
Document Path: /min_extras/ab_tests/minify/test_Groups.php/test
Document Length: 15993 bytes
Requests per second: 225.35 [#/sec] (mean)
(Connect: 0, Length: 2, Exceptions: 0)
Requests per second: 204.15 [#/sec] (mean)
--------------------------------------------------------------------------------
Document Path: /_3rd_party/minify/web/ab_tests/minify/test_Version1.php?files=before.js
Document Path: /min_extras/ab_tests/minify/test_Version1.php?files=before.js
Document Length: 15993 bytes
Requests per second: 234.43 [#/sec] (mean)
(Connect: 0, Length: 2, Exceptions: 0)
Requests per second: 233.58 [#/sec] (mean)
--------------------------------------------------------------------------------
Document Path: /_3rd_party/minify/web/ab_tests/mod_deflate/before.js
Document Path: /min/?f=min_extras/ab_tests/minify/before.js
Document Length: 15993 bytes
(Connect: 0, Length: 1, Exceptions: 0)
Requests per second: 246.63 [#/sec] (mean)
--------------------------------------------------------------------------------
Document Path: /min_extras/ab_tests/mod_deflate/before.js
Document Length: 16053 bytes
Requests per second: 189.07 [#/sec] (mean)
(Connect: 0, Length: 1, Exceptions: 0)
Requests per second: 191.04 [#/sec] (mean)
--------------------------------------------------------------------------------
Document Path: /_3rd_party/minify/web/ab_tests/type-map/before.js.var
Document Path: /min_extras/ab_tests/type-map/before.js.var
Document Length: 15993 bytes
Requests per second: 503.94 [#/sec] (mean)
(Connect: 0, Length: 1, Exceptions: 0)
Requests per second: 518.22 [#/sec] (mean)
--------------------------------------------------------------------------------

View File

@@ -1,9 +1,13 @@
@SET PATH=%PATH%;C:\xampp\apache\bin
::SET ABCALL=ab -d -S -c 100 -n 2000 -H "Accept-Encoding: deflate, gzip" http://localhost
@SET ABCALL=ab -d -S -c 100 -n 2000 -H "Accept-Encoding: deflate, gzip" http://mc.dev/_3rd_party
@SET DOMAIN=http://mc.dev
::SET TXTVIEWER=notepad.exe
::@SET ABCALL=ab -d -S -c 100 -n 2000 -H "Accept-Encoding: deflate, gzip" http://localhost
@SET ABCALL=ab -d -S -c 100 -n 2000 -H "Accept-Encoding: deflate, gzip"
@SET ABTESTS=%DOMAIN%/min_extras/ab_tests
::@SET TXTVIEWER=notepad.exe
@SET TXTVIEWER="C:\Program Files\Notepad++\notepad++.exe"
@SET DELIM=TYPE _delimiter
@@ -11,31 +15,35 @@
DEL results.txt
:: baseline PHP
%ABCALL%/minify/web/ab_tests/ideal_php/before.php >> results.txt
%ABCALL% %ABTESTS%/ideal_php/before.php >> results.txt
@%DELIM% >> results.txt
:: 1.0 release
%ABCALL%/minify/web/ab_tests/v1.0/minify.php?files=before.js >> results.txt
%ABCALL% %ABTESTS%/v1.0/minify.php?files=before.js >> results.txt
@%DELIM% >> results.txt
:: Files controller
%ABCALL%/minify/web/ab_tests/minify/test_Files.php >> results.txt
%ABCALL% %ABTESTS%/minify/test_Files.php >> results.txt
@%DELIM% >> results.txt
:: Groups controller
%ABCALL%/minify/web/ab_tests/minify/test_Groups.php/test >> results.txt
%ABCALL% %ABTESTS%/minify/test_Groups.php/test >> results.txt
@%DELIM% >> results.txt
:: Version1 controller
%ABCALL%/minify/web/ab_tests/minify/test_Version1.php?files=before.js >> results.txt
%ABCALL% %ABTESTS%/minify/test_Version1.php?files=before.js >> results.txt
@%DELIM% >> results.txt
::/min application
%ABCALL% %DOMAIN%/min/?f=min_extras/ab_tests/minify/before.js >> results.txt
@%DELIM% >> results.txt
:: mod_deflate
%ABCALL%/minify/web/ab_tests/mod_deflate/before.js >> results.txt
%ABCALL% %ABTESTS%/mod_deflate/before.js >> results.txt
@%DELIM% >> results.txt
:: type-map
%ABCALL%/minify/web/ab_tests/type-map/before.js.var >> results.txt
%ABCALL% %ABTESTS%/type-map/before.js.var >> results.txt
@%DELIM% >> results.txt
FINDSTR "Path: Length: Requests --" results.txt > results_summary.txt

View File

@@ -13,5 +13,5 @@ ini_set('include_path',
* Set $minifyCachePath to a PHP-writeable path to enable server-side caching
* in all examples and tests.
*/
$minifyCachePath = 'C:/xampp/tmp'; // '';
$minifyCachePath = '';

View File

@@ -3,7 +3,7 @@
$base = realpath(dirname(__FILE__) . '/..');
$groupsSources = array(
'js' => array(
"{$base}/jquery-1.2.3.js"
"{$base}/lib.js"
,"{$base}/test space.js"
)
,'css' => array("{$base}/test.css")

View File

@@ -18,8 +18,8 @@ $cssBuild = new Minify_Build($groupsSources['css']);
<?php if (! $minifyCachePath): ?>
<p><strong>Note:</strong> You should <em>always</em> enable caching using
<code>Minify::useServerCache()</code>. For the examples this can be set in
<code>config.php</code>. Notice that minifying jQuery takes several seconds!.</p>
<code>Minify::setCache()</code>. For the examples this can be set in
<code>config.php</code>.</p>
<?php endif; ?>
<h1>Minify Example 1 : Groups controller + Far-off Expires header</h1>
@@ -40,7 +40,10 @@ changed in the HTML document, causing the browser to request a new version.</p>
</ul>
<h2>Test client cache</h2>
<p><a href="">Reload page</a> <small>(F5 can trigger no-cache headers)</small></p>
<p>When you <a href="">click here</a> to reload the page, your browser should
not have to re-download the minified files.</p>
<p style='text-align:right'><a href="../2/">example 2 &raquo;</a></p>
<script type="text/javascript" src="<?php echo $jsBuild->uri('m.php/js'); ?>"></script>
</body>

View File

@@ -3,7 +3,7 @@
$base = realpath(dirname(__FILE__) . '/..');
$groupsSources = array(
'js' => array(
"{$base}/jquery-1.2.3.js"
"{$base}/lib.js"
,"{$base}/test space.js"
)
,'css' => array("{$base}/test.css")

View File

@@ -26,8 +26,8 @@ ob_start();
<?php if (! $minifyCachePath): ?>
<p><strong>Note:</strong> You should <em>always</em> enable caching using
<code>Minify::useServerCache()</code>. For the examples this can be set in
<code>config.php</code>. Notice that minifying jQuery takes several seconds!.</p>
<code>Minify::setCache()</code>. For the examples this can be set in
<code>config.php</code>.</p>
<?php endif; ?>
<h1>Minify Example 2: Minifying <em>Everything</em></h1>
@@ -40,6 +40,9 @@ elements.</p>
<p>As the document is XHTML, Minify_HTML places the 2nd <code>&lt;script&gt;</code>
element in a CDATA section because it contains "&lt;". The output is valid XHTML.</p>
<h2><a href="http://validator.w3.org/check/referer"
onclick="this.target='_blank'">Validate XHTML</a></h2>
<h2>Minify tests</h2>
<ul>
<li id="cssFail"><span>FAIL</span>PASS</li>
@@ -48,16 +51,21 @@ element in a CDATA section because it contains "&lt;". The output is valid XHTML
</ul>
<h2>Test client cache</h2>
<p><a href="">Reload page</a> <small>(F5 can trigger no-cache headers)</small></p>
<p>When you <a href="">click here</a> to reload the page, your browser should
not have to re-download any files.</p>
<p style='text-align:right'><a href="../../">extras index &raquo;</a></p>
<script type="text/javascript" src="<?php echo $jsBuild->uri('m.php/js'); ?>"></script>
<script type="text/javascript">
$(function () {
var wo = window.onload;
window.onload = function () {
wo && wo();
if ( 1 < 2 ) {
$('#jsFail2').html('PASS');
html('jsFail2', 'PASS');
}
});
};
</script>
</body>

View File

@@ -1,37 +0,0 @@
<?php
require '../../config.php';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Minify Example 3</title>
<link rel="stylesheet" type="text/css" href="m.php?f=test.css" />
<style type="text/css">#cssFail {width:2.8em; overflow:hidden;}</style>
</head>
<body>
<?php if (! $minifyCachePath): ?>
<p><strong>Note:</strong> You should <em>always</em> enable caching using
<code>Minify::useServerCache()</code>. For the examples this can be set in
<code>config.php</code>. Notice that minifying jQuery takes several seconds!.</p>
<?php endif; ?>
<h1>Minify Example 3: Files controller</h1>
<p>This is an example of Minify serving a directory of single css/js files.
Each file is minified and sent with HTTP encoding (browser-permitting).</p>
<h2>Minify tests</h2>
<ul>
<li id="cssFail"><span>FAIL</span>PASS</li>
<li id="jsFail1">FAIL</li>
</ul>
<h2>Test client cache</h2>
<p><a href="">Reload page</a> <small>(F5 can trigger no-cache headers)</small></p>
<script type="text/javascript" src="m.php?f=jquery-1.2.3.js"></script>
<script type="text/javascript" src="m.php?f=test+space.js"></script>
</body>
</html>

View File

@@ -1,44 +0,0 @@
<?php
/**
* This script will serve a single js/css file in this directory. Here we place
* the front-end-controller logic in user code, then use the "Files" controller
* to minify the file. Alternately, we could have created a custom controller
* with the same logic and passed it to Minify::handleRequest().
*/
require '../../config.php';
/**
* The Files controller only "knows" HTML, CSS, and JS files. Other files
* would only be trim()ed and sent as plain/text.
*/
$serveExtensions = array('css', 'js');
// serve
if (isset($_GET['f'])) {
$filename = basename($_GET['f']); // remove any naughty bits
$filenamePattern = '/[^\'"\\/\\\\]+\\.(?:'
.implode('|', $serveExtensions). ')$/';
if (preg_match($filenamePattern, $filename)
&& file_exists(dirname(__FILE__) . '/../' . $filename)) {
require 'Minify.php';
if ($minifyCachePath) {
Minify::setCache($minifyCachePath);
}
// The Files controller can serve an array of files, but here we just
// need one.
Minify::serve('Files', array(
// controller will cast a string to an array for you
'files' => dirname(__FILE__) . '/../' . $filename
));
exit();
}
}
header("HTTP/1.0 404 Not Found");
echo "HTTP/1.0 404 Not Found";

View File

@@ -0,0 +1,3 @@
<?php
header('Location: 1/');

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,6 @@
function html(id, html) {
document.getElementById(id).innerHTML = html;
}

View File

@@ -1,5 +1,5 @@
$(function () {
window.onload = function () {
$('#jsFail1').html('PASS');
html('jsFail1', 'PASS');
});
};

View File

@@ -90,7 +90,7 @@ function test_HTTP_Encoder()
$variedContent = file_get_contents($thisDir . '/_test_files/html/before.html')
. file_get_contents($thisDir . '/_test_files/css/subsilver.css')
. file_get_contents($thisDir . '/../examples/jquery-1.2.3.js');
. file_get_contents($thisDir . '/../ab_tests/minify/before.js');
$variedLength = strlen($variedContent);
$encodingTests = array(