diff --git a/Makefile b/Makefile index 4ec8ad62..52fbdb39 100644 --- a/Makefile +++ b/Makefile @@ -5,6 +5,7 @@ PREFIX = . DOCS_DIR = ${PREFIX}/docs TEST_DIR = ${PREFIX}/test DIST_DIR = ${PREFIX}/dist +SPEED_DIR = ${PREFIX}/speed PLUG_DIR = ../plugins BASE_FILES = ${SRC_DIR}/jquery/jquery.js\ @@ -148,6 +149,21 @@ docs: ${JQ} @@echo "Documentation Built" @@echo +speed: ${JQ} + @@echo "Building Speed Test Suite" + + @@echo " - Making Speed Test Suite Directory:" ${SPEED_DIR} + @@mkdir -p ${SPEED_DIR} + + @@echo " - Copying over script files." + @@cp -f ${BUILD_DIR}/speed/index.html ${SPEED_DIR} + @@cp -f ${BUILD_DIR}/speed/benchmarker.css ${SPEED_DIR} + @@cp -f ${BUILD_DIR}/speed/benchmarker.js ${SPEED_DIR} + @@cp -f ${BUILD_DIR}/speed/jquery-1.1.2.js ${SPEED_DIR} + + @@echo "Speed Test Suite Built" + @@echo + clean: @@echo "Removing Distribution directory:" ${DIST_DIR} @@rm -rf ${DIST_DIR} @@ -157,3 +173,6 @@ clean: @@echo "Removing Documentation directory:" ${DOCS_DIR} @@rm -rf ${DOCS_DIR} + + @@echo "Removing Speed Test Suite directory:" ${SPEED_DIR} + @@rm -rf ${SPEED_DIR} diff --git a/build/speed/benchmarker.css b/build/speed/benchmarker.css new file mode 100755 index 00000000..6fc8154c --- /dev/null +++ b/build/speed/benchmarker.css @@ -0,0 +1,65 @@ + + .dialog { + margin-bottom: 1em; + } + a.expand { + background: #e3e3e3; + } + + div#time-test { + font-family: Arial, Helvetica, sans-serif; + font-size: 62.5%; + } + + td.test button { + float: right; + } + + table { + border: 1px solid #000; + } + + table td, table th { + border: 1px solid #000; + padding: 10px; + } + + td.winner { + background-color: #cfc; + } + + td.tie { + background-color: #ffc; + } + + td.fail { + background-color: #f99; + font-weight: bold; + text-align: center; + } + + tfoot td { + text-align: center; + } + + #time-test { + margin: 1em 0; + padding: .5em; + background: #e3e3e3; + } + #time-taken { + font-weight: bold; + } + + span.wins { + color: #330; + } + + span.fails { + color: #900; + } + + div.buttons { + margin-top: 10px; + margin-bottom: 10px; + } \ No newline at end of file diff --git a/build/speed/benchmarker.js b/build/speed/benchmarker.js new file mode 100755 index 00000000..a04e5acc --- /dev/null +++ b/build/speed/benchmarker.js @@ -0,0 +1,159 @@ + jQuery.benchmarker.tests = [ + "*", + "body", "body div", "div", + "div div div", "div div", ".dialog", "div.dialog", "div .dialog", + "#speech5", "div#speech5", "div #speech5", "div > div", "div.scene div.dialog", + "div#scene1.scene div.dialog div", "#scene1 #speech1", "body > div.dialog div#speech5", + "div:nth-child(even)", "div:nth-child(odd)", + "div:nth-child(1)", "div:nth-child(2n)", + "div:nth-child(2n+3)", "div:first-child", + "div:last-child", "div:only-child", + "div:contains(CELIA)", + "div ~ div", "div + div", + "div[@class]", "div[@class=dialog]", "div[@class!=dialog]", + "div[@class^=dialog]", "div[@class$=dialog]", "div[@class*=dialog]" + ] + + jQuery.fn.benchmark = function() { + this.each(function() { + try { + jQuery(this).parent().children("*:gt(1)").remove(); + } catch(e) { } + }) + var times = 5; + jQuery("#times").html(times); + jQuery.benchmarker.startingList = this.get(); + benchmark(this.get(), times, jQuery.benchmarker.libraries); + } + + jQuery(function() { + for(i = 0; i < jQuery.benchmarker.tests.length; i++) { + jQuery("tbody").append("
Using the following selector expressions (5 times each):
+NOTE: Number shown is an average.
+ +Run? | +Test | + +
---|---|
+ | + |
+ + | + |
+ | + |