mirror of
https://github.com/odoo/owl.git
synced 2025-10-06 19:59:41 +07:00
[ADD] extras: add owl 0.10.0 to list of benchmarks
This commit is contained in:
@@ -0,0 +1,84 @@
|
|||||||
|
import { buildData, startMeasure, stopMeasure } from "../shared/utils.js";
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Likes Counter Widget
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
class Counter extends owl.Component {
|
||||||
|
template = "counter";
|
||||||
|
state = { counter: 0 };
|
||||||
|
|
||||||
|
increment() {
|
||||||
|
this.state.counter++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Message Widget
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
class Message extends owl.Component {
|
||||||
|
template = "message";
|
||||||
|
widgets = { Counter };
|
||||||
|
|
||||||
|
shouldUpdate(nextProps) {
|
||||||
|
return nextProps !== this.props;
|
||||||
|
}
|
||||||
|
removeMessage() {
|
||||||
|
this.trigger("remove_message", {
|
||||||
|
id: this.props.id
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Root Widget
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
class App extends owl.Component {
|
||||||
|
template = "root";
|
||||||
|
widgets = { Message };
|
||||||
|
state = { messages: [] };
|
||||||
|
|
||||||
|
addMessages(n) {
|
||||||
|
startMeasure("add " + n);
|
||||||
|
const newMessages = buildData(n);
|
||||||
|
this.state.messages.push.apply(this.state.messages, newMessages);
|
||||||
|
stopMeasure();
|
||||||
|
}
|
||||||
|
|
||||||
|
clear() {
|
||||||
|
startMeasure("clear");
|
||||||
|
this.state.messages = [];
|
||||||
|
stopMeasure();
|
||||||
|
}
|
||||||
|
|
||||||
|
updateSomeMessages() {
|
||||||
|
startMeasure("update every 10th");
|
||||||
|
const messages = this.state.messages;
|
||||||
|
for (let i = 0; i < this.state.messages.length; i += 10) {
|
||||||
|
const msg = Object.assign({}, messages[i]);
|
||||||
|
msg.author += '!!!';
|
||||||
|
this.set(messages, i, msg);
|
||||||
|
}
|
||||||
|
stopMeasure();
|
||||||
|
}
|
||||||
|
|
||||||
|
removeMessage(data) {
|
||||||
|
startMeasure("remove message");
|
||||||
|
const index = this.state.messages.findIndex(m => m.id === data.id);
|
||||||
|
this.state.messages.splice(index, 1);
|
||||||
|
stopMeasure();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
// Application initialization
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
async function start() {
|
||||||
|
const templates = await owl.utils.loadTemplates("templates.xml");
|
||||||
|
const env = {
|
||||||
|
qweb: new owl.QWeb(templates)
|
||||||
|
};
|
||||||
|
const app = new App(env);
|
||||||
|
app.mount(document.body);
|
||||||
|
}
|
||||||
|
|
||||||
|
start();
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>OWL 0.10.0 Benchmark</title>
|
||||||
|
<link href="../shared/main.css" rel="stylesheet"/>
|
||||||
|
<script src='owl.js'></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id='main'></div>
|
||||||
|
<script src='app.js' type="module"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,32 @@
|
|||||||
|
<templates>
|
||||||
|
<div t-name="root" class="main">
|
||||||
|
<div class="left-thing">
|
||||||
|
<div>Number of msg: <t t-esc="state.messages.length"/></div>
|
||||||
|
<button t-on-click="addMessages(100)">Add 100 messages</button>
|
||||||
|
<button t-on-click="addMessages(1000)">Add 1000 messages</button>
|
||||||
|
<button t-on-click="addMessages(10000)">Add 10000 messages</button>
|
||||||
|
<button t-on-click="addMessages(50000)">Add 50000 messages</button>
|
||||||
|
<button t-on-click="updateSomeMessages">Update every 10th message</button>
|
||||||
|
<button t-on-click="clear">Clear</button>
|
||||||
|
</div>
|
||||||
|
<div class="right-thing">
|
||||||
|
<div class="content">
|
||||||
|
<t t-foreach="state.messages" t-as="message">
|
||||||
|
<t t-widget="Message" t-key="message.id" t-props="message" t-on-remove_message="removeMessage"/>
|
||||||
|
</t>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div t-name="message" class="message">
|
||||||
|
<span class="author"><t t-esc="props.author"/></span>
|
||||||
|
<span class="msg"><t t-esc="props.msg"/></span>
|
||||||
|
<button class="remove" t-on-click="removeMessage">Remove</button>
|
||||||
|
<t t-widget="Counter"/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div t-name="counter">
|
||||||
|
<button t-on-click="increment">Value: <t t-esc="state.counter"/></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</templates>
|
||||||
@@ -17,6 +17,7 @@
|
|||||||
<li><a href="benchmarks/owl-0.7.0">OWL 0.7.0</a></li>
|
<li><a href="benchmarks/owl-0.7.0">OWL 0.7.0</a></li>
|
||||||
<li><a href="benchmarks/owl-0.8.0">OWL 0.8.0</a></li>
|
<li><a href="benchmarks/owl-0.8.0">OWL 0.8.0</a></li>
|
||||||
<li><a href="benchmarks/owl-0.9.0">OWL 0.9.0</a></li>
|
<li><a href="benchmarks/owl-0.9.0">OWL 0.9.0</a></li>
|
||||||
|
<li><a href="benchmarks/owl-0.10.0">OWL 0.10.0</a></li>
|
||||||
<li><a href="benchmarks/owl-master">OWL Master</a></li>
|
<li><a href="benchmarks/owl-master">OWL Master</a></li>
|
||||||
<li><a href="benchmarks/vue">Vue</a></li>
|
<li><a href="benchmarks/vue">Vue</a></li>
|
||||||
<li><a href="benchmarks/react">React</a></li>
|
<li><a href="benchmarks/react">React</a></li>
|
||||||
|
|||||||
Reference in New Issue
Block a user