From 2c218c4463050e2d2a7dbc613ff852d018d0b36d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Wed, 17 Apr 2019 16:22:33 +0200 Subject: [PATCH] [REM] examples: remove benchmarks app This will be moved in a different branch closes #44 --- examples/benchmarks/app.css | 45 ------------------------------ examples/benchmarks/app.js | 51 ---------------------------------- examples/benchmarks/counter.js | 18 ------------ examples/benchmarks/data.js | 22 --------------- examples/benchmarks/index.html | 16 ----------- examples/benchmarks/main.js | 13 --------- examples/benchmarks/message.js | 22 --------------- examples/readme.md | 20 ------------- 8 files changed, 207 deletions(-) delete mode 100644 examples/benchmarks/app.css delete mode 100644 examples/benchmarks/app.js delete mode 100644 examples/benchmarks/counter.js delete mode 100644 examples/benchmarks/data.js delete mode 100644 examples/benchmarks/index.html delete mode 100644 examples/benchmarks/main.js delete mode 100644 examples/benchmarks/message.js delete mode 100644 examples/readme.md diff --git a/examples/benchmarks/app.css b/examples/benchmarks/app.css deleted file mode 100644 index 7fa565c3..00000000 --- a/examples/benchmarks/app.css +++ /dev/null @@ -1,45 +0,0 @@ -.main { - position: absolute; - left: 0; - right: 0; - top: 0; - bottom: 0; - - display: grid; - grid-template-columns: 200px 1fr; -} - -.left-thing { - background-color: gray; - padding: 20px; -} - -.left-thing button { - width: 100%; -} - -.left-thing .counter span { - color: white; -} - -.left-thing .counter button { - width: 40px; -} - -.right-thing { - padding: 20px; - overflow: auto; -} - -/* Message widget */ -.message .author { - font-weight: bold; -} - -.message { - width: 400px; - background-color: lightblue; - margin: 10px 5px; - border-radius: 5px; - padding: 5px; -} diff --git a/examples/benchmarks/app.js b/examples/benchmarks/app.js deleted file mode 100644 index e842a4e4..00000000 --- a/examples/benchmarks/app.js +++ /dev/null @@ -1,51 +0,0 @@ -import { Message } from "./message.js"; -import { messages } from "./data.js"; - -const template = ` -
-
-
- - Value: - -
- - - - - - -
-
-
- - - -
-
-
`; - -export class App extends owl.Component { - constructor(parent, props) { - super(parent, props); - this.inlineTemplate = template; - this.widgets = { Message }; - this.state = { - messages: messages.slice(0, 10) - }; - } - - setMessageCount(n) { - this.state.messages = messages.slice(0, n); - } - - removeMessage(data) { - const index = messages.findIndex(m => m.id === data.id); - this.state.messages.splice(index, 1); - } - - increment(delta) { - const n = this.state.messages.length + delta; - this.setMessageCount(n); - } -} diff --git a/examples/benchmarks/counter.js b/examples/benchmarks/counter.js deleted file mode 100644 index 39156c0f..00000000 --- a/examples/benchmarks/counter.js +++ /dev/null @@ -1,18 +0,0 @@ -export class Counter extends owl.Component { - inlineTemplate = ` -
- - Value: - -
`; - constructor(parent, props) { - super(parent, props); - this.state = { - counter: props.initialState || 0 - }; - } - - increment(delta) { - this.state.counter += delta; - } -} diff --git a/examples/benchmarks/data.js b/examples/benchmarks/data.js deleted file mode 100644 index 220d42e0..00000000 --- a/examples/benchmarks/data.js +++ /dev/null @@ -1,22 +0,0 @@ -export const messages = []; - -const authors = ["Aaron", "David", "Vincent"]; -const content = [ - "Lorem ipsum dolor sit amet", - "Sed ut perspiciatis unde omnis iste natus error sit voluptatem", - "Excepteur sint occaecat cupidatat non proident" -]; - -function chooseRandomly(array) { - const index = Math.floor(Math.random() * array.length); - return array[index]; -} - -for (let i = 1; i < 16000; i++) { - messages.push({ - id: i, - author: chooseRandomly(authors), - msg: `${i}: ${chooseRandomly(content)}`, - likes: 0 - }); -} diff --git a/examples/benchmarks/index.html b/examples/benchmarks/index.html deleted file mode 100644 index d190dc2f..00000000 --- a/examples/benchmarks/index.html +++ /dev/null @@ -1,16 +0,0 @@ - - - - - Odoo WebCore Benchmarks App - - - - - - - - - - - \ No newline at end of file diff --git a/examples/benchmarks/main.js b/examples/benchmarks/main.js deleted file mode 100644 index 6f919df4..00000000 --- a/examples/benchmarks/main.js +++ /dev/null @@ -1,13 +0,0 @@ -import { App } from "./app.js"; - -function createApp(el) { - const env = { - qweb: new owl.QWeb() - }; - const app = new App(env, { initialState: 13 }); - app.mount(el); -} - -document.addEventListener("DOMContentLoaded", function() { - createApp(document.body); -}); diff --git a/examples/benchmarks/message.js b/examples/benchmarks/message.js deleted file mode 100644 index 74501733..00000000 --- a/examples/benchmarks/message.js +++ /dev/null @@ -1,22 +0,0 @@ -import { Counter } from "./counter.js"; - -export class Message extends owl.Component { - inlineTemplate = ` -
- - - - -
`; - - constructor(parent, props) { - super(parent, props); - this.widgets = { Counter }; - } - - removeMessage() { - this.trigger("remove_message", { - id: this.props.id - }); - } -} diff --git a/examples/readme.md b/examples/readme.md deleted file mode 100644 index 814d4112..00000000 --- a/examples/readme.md +++ /dev/null @@ -1,20 +0,0 @@ -# Examples - -This project features three example to illustrate how to work with the web-core framework: - -- _benchmarks_ is a small application to test large number of widgets, - -## Benchmarks - -This example is just a playground to experiment/showcase some features of the framework, with large number of widgets. - -``` -npm run example:benchmarks:build # make a build in dist/examples/ -npm run example:benchmarks:dev # make a build in dist/examples/, and make a live server to access it -``` - -The benchmarks application generates a large number of demo messages, and display them in a list, with a few buttons that can -be used to alter the number of visible widgets. - -Note that each message is itself a widget, with a sub widget. This -example could be made faster (by not using subwidgets), but the point is to observe/measure the overhead of the Component class.