Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
#!/bin/bash
jsfile=${1};
testruns=1000
yuicompressor=./yuicompressor-2.4.5pre.jar;
yuicompressorServer="curl --silent http://localhost:8888/compress?type=js -T";
closurecompiler="./gcj.jar --compilation_level SIMPLE_OPTIMIZATIONS --js";
uglifyjs="uglifyjs";
echo "Running Compressor Tests on ${jsfile}...";
echo "Creating unminned gzip...";
gzip -c $jsfile > $jsfile.gz;
echo "Creating YUI Compressor Minned File...";
java -jar $yuicompressor $jsfile > $jsfile.yuicompressor
gzip $jsfile.yuicompressor -c > $jsfile.yuicompressor.gz
echo "Creating UglifyJS Minned File...";
uglifyjs $jsfile > $jsfile.uglifyjs
gzip $jsfile.uglifyjs -c > $jsfile.uglifyjs.gz
echo "Creating Closure Compiler Minned File...";
java -jar $closurecompiler $jsfile > $jsfile.closure
gzip $jsfile.closure -c > $jsfile.closure.gz
echo "Starting YUI Compressor Sever...";
java -jar $yuicompressor --server 8888 &
echo "Collect UglifyJS Data...";
rm $jsfile.raw 2> /dev/null
for i in `seq 1 ${testruns}`; do
/usr/bin/time $uglifyjs $jsfile > /dev/null 2>> $jsfile.raw
done
awk 'BEGIN{ FS=" " }{ if ( $3 ~ /elapsed/ ) { print substr($3, 1, 7) }}' $jsfile.raw > $jsfile.uglify.elapsed;
echo "Collect YUICompressor Data...";
rm $jsfile.raw 2> /dev/null
for i in `seq 1 ${testruns}`; do
/usr/bin/time java -jar $yuicompressor $jsfile > /dev/null 2>> $jsfile.raw
done
awk 'BEGIN{ FS=" " }{ if ( $3 ~ /elapsed/ ) { print substr($3, 1, 7) }}' $jsfile.raw > $jsfile.yuicompressor.elapsed;
echo "Collect YUICompressor Server Data...";
rm $jsfile.raw 2> /dev/null
for i in `seq 1 ${testruns}`; do
/usr/bin/time $yuicompressorServer $jsfile > /dev/null 2>> $jsfile.raw
done
awk 'BEGIN{ FS=" " }{ if ( $3 ~ /elapsed/ ) { print substr($3, 1, 7) }}' $jsfile.raw > $jsfile.yuicompressor-server.elapsed;
rm $jsfile.raw 2> /dev/null
echo "Collect Closure Compiler Data...";
rm $jsfile.raw 2> /dev/null
for i in `seq 1 ${testruns}`; do
/usr/bin/time java -jar $closurecompiler $jsfile > /dev/null 2>> $jsfile.raw
done
awk 'BEGIN{ FS=" " }{ if ( $3 ~ /elapsed/ ) { print substr($3, 1, 7) }}' $jsfile.raw > $jsfile.closurecompiler.elapsed;
rm $jsfile.raw 2> /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment