Skip to content
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

[FEATURE Beta] Benchmarks #3903

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ _yardoc
assets
assets/bpm_libs.js
assets/bpm_styles.css
benchmarks/node_modules
benchmarks/tmp
bin/
coverage
dist
Expand Down
34 changes: 34 additions & 0 deletions benchmarks/Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
module.exports = function(grunt) {
var fs = require('fs');
require('load-grunt-tasks')(grunt);
var config = require('load-grunt-config')(grunt, {
configPath: 'tasks/options',
init: false
});

grunt.loadTasks('tasks');

config.env = process.env;
config.pkg = grunt.file.readJSON('package.json');

grunt.registerTask('createConfig', function() {
var path = config.pkg.directories.implementations,
configPath = config.pkg.config,
data = [],
files = fs.readdirSync('./' + path);

data = [
'var logToConsole = ' + config.pkg.logToConsole + ',\r\n',
'\t\timplementations = "' + files + '";\r\n',
'export { logToConsole, implementations };'
];

fs.writeFileSync(configPath, data.join(''));
});

this.registerTask('default', ['build']);
this.registerTask('server', ['build', 'connect', 'watch']);
this.registerTask('build', ['clean', 'createConfig', 'transpile', 'concat:browser']);

grunt.initConfig(config);
};
53 changes: 47 additions & 6 deletions benchmarks/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,48 @@
# Extremely simple Ember benchmarks
## Ember Benchmarks

To run the benchmarks, serve the repository root on a web server (`gem install
asdf; asdf`), run `rake` to build Ember, and open e.g.
`http://localhost:9292/benchmarks/index.html?suitePath=plain_object.js` to run
`benchmarks/suites/plain_object.js`. Run `cp -r dist distold` to benchmark
different versions against each other.
```bash
npm install && grunt server
```

Open [localhost:8000](http://localhost:8000) in your browser.

### Folder structure

```
+ css
// styles for the benchmarks UI
+ implementations
// different versions of `Ember` that you want to run benchmarks against
+ lib
+ dependecies
// other libraries that `Ember` depends on (jquery and handlebars)
+ suites
// benchmarks
+ vendor
// external dependencies for benchmark UI
```

### Files

+ `lib/app.js` is an `Ember` application that powers the UI
+ `lib/benchmark-runner` runs benchmarks and talks to the UI
+ `lib/runner` kicks off benchmarks execution
+ `lib/iframe-wrapper` wraps benchmarks and all dependecies in an iframe
and appends to the main `document`
+ 'lib/config.js` is a place where benchmark configuration options
reside.


### Adding new benchmark

First, you need to add an actual benchmark test under `suites` folder.
You will need to import `benchmark.js` itself.

After you're done writing the new benchmark, you need to add it to the
list of the benchmarks that are run each time. You need to edit
`lib/benchmarks.js` and add something like this: `import { suite as
new_bench } from './suites/new-benchmarks/new-benchmark'` and also
change `benchmarks` array (add `new-benchmark` as an element).

Note: benchmarks are written using ES6 modules and ES6 module
transpiler.
Loading