From 6d65cb77ecc0eb8f2cf79b2ed61165a3e71a1e4a Mon Sep 17 00:00:00 2001 From: John-David Dalton Date: Sat, 13 Jul 2013 16:39:18 -0700 Subject: [PATCH] Make perf-ui.js and test-ui.js more aligned, remove `unzip` perf test, and handle comparing to files of the same name in perf.js. Former-commit-id: 7a5353aab76d6667b6dd5d43e85f95695e5a9cba --- perf/perf-ui.js | 4 ++-- perf/perf.js | 22 +++++----------------- test/test-ui.js | 8 ++++---- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/perf/perf-ui.js b/perf/perf-ui.js index e12c28ff9..ca8c9c482 100644 --- a/perf/perf-ui.js +++ b/perf/perf-ui.js @@ -24,7 +24,7 @@ * @param {Function} handler The event handler. * @returns {Element} The element. */ - function addEvent(element, eventName, handler) { + function addListener(element, eventName, handler) { if (typeof element.addEventListener != 'undefined') { element.addEventListener(eventName, handler, false); } else if (typeof element.attachEvent != 'undefined') { @@ -77,7 +77,7 @@ }()); // initialize controls - addEvent(window, 'load', function() { + addListener(window, 'load', function() { function eventHandler(event) { var search = location.search.replace(/^\?|&?(?:build|other)=[^&]*&?/g, ''); if (event.stopPropagation) { diff --git a/perf/perf.js b/perf/perf.js index da7137ceb..e49194449 100644 --- a/perf/perf.js +++ b/perf/perf.js @@ -76,7 +76,10 @@ var buildName = window.buildName = basename(ui.buildPath, '.js'); /** The other library basename */ - var otherName = window.otherName = basename(ui.otherPath, '.js'); + var otherName = window.otherName = (function() { + var result = basename(ui.otherPath, '.js'); + return result + (result == buildName ? ' (2)' : ''); + }()); /** Detect if in a browser environment */ var isBrowser = isHostType(window, 'document') && isHostType(window, 'navigator'); @@ -527,8 +530,7 @@ whereObject = { "num": 9 };\ }\ if (typeof zip != "undefined") {\ - var unzipped = [["a", "b", "c"], [1, 2, 3], [true, false, true]],\ - zipped = [["a", 1, true], ["b", 2, false], ["c", 3, true]];\ + var unzipped = [["a", "b", "c"], [1, 2, 3], [true, false, true]];\ }' }); @@ -1828,20 +1830,6 @@ /*--------------------------------------------------------------------------*/ - suites.push( - Benchmark.Suite('`_.unzip`') - .add(buildName, { - 'fn': 'lodash.unzip(zipped)', - 'teardown': 'function zip(){}' - }) - .add(otherName, { - 'fn': '_.unzip(zipped)', - 'teardown': 'function zip(){}' - }) - ); - - /*--------------------------------------------------------------------------*/ - suites.push( Benchmark.Suite('`_.values`') .add(buildName, '\ diff --git a/test/test-ui.js b/test/test-ui.js index 423752d0d..319d55852 100644 --- a/test/test-ui.js +++ b/test/test-ui.js @@ -24,7 +24,7 @@ * @param {Function} handler The event handler. * @returns {Element} The element. */ - function addEvent(element, eventName, handler) { + function addListener(element, eventName, handler) { if (typeof element.addEventListener != 'undefined') { element.addEventListener(eventName, handler, false); } else if (typeof element.attachEvent != 'undefined') { @@ -74,7 +74,7 @@ }()); // initialize controls - addEvent(window, 'load', function() { + addListener(window, 'load', function() { function eventHandler(event) { var search = location.search.replace(/^\?|&?(?:build|loader)=[^&]*&?/g, ''); if (event.stopPropagation) { @@ -123,8 +123,8 @@ return -1; }()); - addEvent(buildList, 'change', eventHandler); - addEvent(loaderList, 'change', eventHandler); + addListener(buildList, 'change', eventHandler); + addListener(loaderList, 'change', eventHandler); } else { setTimeout(init, 15);