Skip to content

Update benchmarks to use production version of react and compiled JSX templates. #18

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

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
48 changes: 24 additions & 24 deletions perf/todomvc-benchmark/results.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,40 @@
"Chrome": {
"version": 32,
"data": {
"Vue": 513.4351000189781,
"Backbone": 905.215000017779,
"Knockout": 479.85350001836196,
"Ember": 2041.034799994668,
"Angular": 2284.198399982415,
"React": 2159.7387000045273,
"Om": 531.0522000072524,
"Ractive": 1299.3730999995023
"Vue": 517.1309999423102,
"Backbone": 766.0240000113845,
"Knockout": 466.5719998884015,
"Ember": 1470.551999984309,
"Angular": 1421.3290000916459,
"React": 1366.7290000012144,
"Om": 422.92199993971735,
"Ractive": 1009.0529999579303
}
},
"Firefox": {
"version": 26,
"data": {
"Vue": 563.2124097999965,
"Backbone": 804.2158809000063,
"Knockout": 498.9543262000112,
"Ember": 2303.997436800003,
"Angular": 2189.604799899995,
"React": 1334.863771099995,
"Om": 576.9800275999982,
"Ractive": 1776.5675642999904
"Vue": 604.8002719999986,
"Backbone": 1057.144711,
"Knockout": 560.318631000001,
"Ember": 2023.1656529999982,
"Angular": 1153.135662000006,
"React": 1062.1933359999966,
"Om": 520.8095430000012,
"Ractive": 1845.2588180000002
}
},
"Safari": {
"version": 7,
"data": {
"Vue": 263.5,
"Backbone": 906.3,
"Knockout": 544.5,
"Ember": 1576.1,
"Angular": 1956,
"React": 1022.5,
"Om": 545.5,
"Ractive": 1115.6
"Vue": 351,
"Backbone": 894,
"Knockout": 666,
"Ember": 1933,
"Angular": 3095,
"React": 1308,
"Om": 648,
"Ractive": 2557
}
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@
<footer id="info"></footer>
<div id="benchmark"></div>

<script src="bower_components/react/react-with-addons.js"></script>
<script src="bower_components/react/JSXTransformer.js"></script>
<script src="bower_components/director/build/director.js"></script>
<!-- <script src="bower_components/react/react-with-addons.js"></script> -->
<!-- <script src="bower_components/director/build/director.js"></script> -->
<script type="text/javascript" src="production/react.min.js"></script>
<script type="text/javascript" src="production/director.min.js"></script>

<script type="text/jsx" src="js/utils.jsx"></script>
<script type="text/jsx" src="js/todoItem.jsx"></script>
<script type="text/jsx" src="js/footer.jsx"></script>
<script type="text/jsx" src="js/app.jsx"></script>
<script type="text/javascript" src="js/utils.js"></script>
<script type="text/javascript" src="js/todoItem.js"></script>
<script type="text/javascript" src="js/footer.js"></script>
<script type="text/javascript" src="js/app.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
/**
* @jsx React.DOM
*/
/*jshint quotmark:false */
/*jshint white:false */
/*jshint trailing:false */
/*jshint newcap:false */
/*global Utils, ALL_TODOS, ACTIVE_TODOS, COMPLETED_TODOS,
TodoItem, TodoFooter, React, Router*/

(function (window, React) {
'use strict';

window.ALL_TODOS = 'all';
window.ACTIVE_TODOS = 'active';
window.COMPLETED_TODOS = 'completed';

var ENTER_KEY = 13;

var TodoApp = React.createClass({displayName: 'TodoApp',
getInitialState: function () {
var todos = Utils.store('react-todos');
return {
todos: todos,
nowShowing: ALL_TODOS,
editing: null
};
},

componentDidMount: function () {
var router = Router({
'/': this.setState.bind(this, {nowShowing: ALL_TODOS}),
'/active': this.setState.bind(this, {nowShowing: ACTIVE_TODOS}),
'/completed': this.setState.bind(this, {nowShowing: COMPLETED_TODOS})
});
router.init();
this.refs.newField.getDOMNode().focus();
},

handleNewTodoKeyDown: function (event) {
if (event.which !== ENTER_KEY) {
return;
}

var val = this.refs.newField.getDOMNode().value.trim();
var newTodo;

if (val) {
newTodo = {
id: Utils.uuid(),
title: val,
completed: false
};
this.setState({todos: this.state.todos.concat([newTodo])});
this.refs.newField.getDOMNode().value = '';
}

return false;
},

toggleAll: function (event) {
var checked = event.target.checked;

// Note: it's usually better to use immutable data structures since they're easier to
// reason about and React works very well with them. That's why we use map() and filter()
// everywhere instead of mutating the array or todo items themselves.
var newTodos = this.state.todos.map(function (todo) {
return Utils.extend({}, todo, {completed: checked});
});

this.setState({todos: newTodos});
},

toggle: function (todoToToggle) {
var newTodos = this.state.todos.map(function (todo) {
return todo !== todoToToggle ? todo : Utils.extend({}, todo, {completed: !todo.completed});
});

this.setState({todos: newTodos});
},

destroy: function (todo) {
var newTodos = this.state.todos.filter(function (candidate) {
return candidate.id !== todo.id;
});

this.setState({todos: newTodos});
},

edit: function (todo, callback) {
// refer to todoItem.js `handleEdit` for the reasoning behind the
// callback
this.setState({editing: todo.id}, function () {
callback();
});
},

save: function (todoToSave, text) {
var newTodos = this.state.todos.map(function (todo) {
return todo !== todoToSave ? todo : Utils.extend({}, todo, {title: text});
});

this.setState({todos: newTodos, editing: null});
},

cancel: function () {
this.setState({editing: null});
},

clearCompleted: function () {
var newTodos = this.state.todos.filter(function (todo) {
return !todo.completed;
});

this.setState({todos: newTodos});
},

componentDidUpdate: function () {
Utils.store('react-todos', this.state.todos);
},

render: function () {
var footer = null;
var main = null;

var shownTodos = this.state.todos.filter(function (todo) {
switch (this.state.nowShowing) {
case ACTIVE_TODOS:
return !todo.completed;
case COMPLETED_TODOS:
return todo.completed;
default:
return true;
}
}, this);

var todoItems = shownTodos.map(function (todo) {
return (
TodoItem(
{key:todo.id,
todo:todo,
onToggle:this.toggle.bind(this, todo),
onDestroy:this.destroy.bind(this, todo),
onEdit:this.edit.bind(this, todo),
editing:this.state.editing === todo.id,
onSave:this.save.bind(this, todo),
onCancel:this.cancel}
)
);
}, this);

var activeTodoCount = this.state.todos.reduce(function(accum, todo) {
return todo.completed ? accum : accum + 1;
}, 0);

var completedCount = this.state.todos.length - activeTodoCount;

if (activeTodoCount || completedCount) {
footer =
TodoFooter(
{count:activeTodoCount,
completedCount:completedCount,
nowShowing:this.state.nowShowing,
onClearCompleted:this.clearCompleted}
);
}

if (this.state.todos.length) {
main = (
React.DOM.section( {id:"main"},
React.DOM.input(
{id:"toggle-all",
type:"checkbox",
onChange:this.toggleAll,
checked:activeTodoCount === 0}
),
React.DOM.ul( {id:"todo-list"},
todoItems
)
)
);
}

return (
React.DOM.div(null,
React.DOM.header( {id:"header"},
React.DOM.h1(null, "todos"),
React.DOM.input(
{ref:"newField",
id:"new-todo",
placeholder:"What needs to be done?",
onKeyDown:this.handleNewTodoKeyDown}
)
),
main,
footer
)
);
}
});

React.renderComponent(TodoApp(null ), document.getElementById('todoapp'));
React.renderComponent(
React.DOM.div(null,
React.DOM.p(null, "Double-click to edit a todo"),
React.DOM.p(null, "Created by",' ',
React.DOM.a( {href:"http://github.com/petehunt/"}, "petehunt")
),
React.DOM.p(null, "Part of",' ',React.DOM.a( {href:"http://todomvc.com"}, "TodoMVC"))
),
document.getElementById('info'));
})(window, React);
Loading