-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No mechanism for including dependencies #1
Comments
The Worth noting that outside of the context of YUI development, the workflow for requesting assets is a little annoying, as you'd have to list all dependencies in your application, then dynamically load in those scripts in a setup function. Within the context of YUI, it's easy because YUI's loader makes it easy. YUI Benchmark's initial release was solely to ease the pain of perf testing for development on YUI's core, with Gallery development being a secondary priority, and non-YUI development being third. So this is something that could certainly be improved in the future. FWIW, YUI's Node performance tests are a good example of something that uses the Leaving this ticket open as a reminder to improve the asset handling logic. |
As of now, the way to get external scripts to work is loading them synchronously using jQuery. A sample test suite would look like var suite = new PerfSuite({
name: 'Sync load JS dependencies',
jquery: true,
assets: [
'path/to/file.js'
],
global: {
setup: function () {
if (!window.assetsLoaded) {
$.ajaxSetup({ async: false });
$.getScript('assets/file.js');
window.assetsLoaded = true;
}
}
}
});
suite.add({
name: 'my test',
async: true,
fn: function () {
// you can use globals from your asset file.js in these tests
}
}); |
@derek Do you have the API in mind? The API can be in one of the following ways. 1> Allow a suite property as additional content of var suite = new PerfSuite({
assets: ['path/file.js'],
headHTML: '<script src='file.js'></script>'
}); I don't quite like the 2> Allow a new suite option called var suite = new PerfSuite({
assets: ['path/file.js', 'path/file.css'],
fixtures: {
'application/javascript': ['file.js'],
'text/css': ['file.css']
}
}); This looks a bit nerdy API, but is extensible in the long run and much more managed. The "nerdy-ness" can be reduced if we simply call the keys "javascript" and "css" instead of the mime-types. PS: The present asset loading mechanism prevents loading two files from different paths with same name. |
Early in development, there were two HTML options ( In the second suggestion, I'd prefer to simply list the files to include in an array ( |
Additional thought... I like the idea of including those files in the existing Short-hand
Long-hand (exact option names TBD)
|
This API even solves the issue with assets not being able to load same file name with different paths. :-) Can you explain By this long-form method, user has to specify the |
I believe there would be two areas where you would want to include assets, in the If Oh, also
It should be possible to mix long-form and short-form in the |
To my mind a serious drawback to an otherwise very interesting tool. Shamasis' suggestion to use jQuery goes some way towards a solution, but doesn't seem to address the issue of establishing global (module namespacing) variables à la node.js: var vows = require('vows')
, assert = require('assert')
, teoria = require('teoria')
, piu = require('../index');
: Before noticing the existence of this issue (why no mention in the readme?), I had already placed a related question on stackoverflow. I have neither the knowledge nor skills to resolve this, but feel that without a fix, yui-benchmark will fail to be adopted. |
I'm trying to include dependencies (other than jQuery), such as the actual code I want to test. So far, I tried:
html
option to dump in<script src="somedep.js"></script>
yb
Without starting an additional server and referencing files hosted on it via
<script>
tags placed in thehtml
option, I can't find a way to do this.The text was updated successfully, but these errors were encountered: