| Index: test/perf/input/todomvc_async_test.html
|
| diff --git a/test/data/input/todomvc_listorder_shadowdom_test.html b/test/perf/input/todomvc_async_test.html
|
| similarity index 67%
|
| copy from test/data/input/todomvc_listorder_shadowdom_test.html
|
| copy to test/perf/input/todomvc_async_test.html
|
| index 1ed1bc5f982a1c1df5b048ca1b407ae34cacbac2..7e629adcbca7c735fc81b8720f9566cf713b2fa3 100644
|
| --- a/test/data/input/todomvc_listorder_shadowdom_test.html
|
| +++ b/test/perf/input/todomvc_async_test.html
|
| @@ -7,12 +7,15 @@ BSD-style license that can be found in the LICENSE file.
|
| <html lang="en">
|
| <head>
|
| <!--
|
| - This test runs the TodoMVC app, adds a few elements, marks some as done, and
|
| - switches from back and forth between "Active" and "All". This will make some
|
| - nodes to be hidden and readded to the page.
|
| + This performance test runs the TodoMVC app and uses the application as follows:
|
| + * on each iteration:
|
| + * clear all todos
|
| + * add 5 todos
|
| + * mark 1 as done
|
| + * clear the todo marked as done.
|
|
|
| - This is a regression test for a bug in dwc that made the nodes appear in the
|
| - wrong order when using lists and ifs together.
|
| + This test is just like todomvc_test.html, but we use requestLayoutFrame
|
| + between rendering steps (after adding each note, or removing a note).
|
| -->
|
| <meta charset="utf-8">
|
| <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
|
| @@ -20,6 +23,7 @@ BSD-style license that can be found in the LICENSE file.
|
| <link rel="components" href="example/todomvc/todo_row.html">
|
| <link rel="stylesheet" href="example/todomvc/base.css">
|
| <script type="application/javascript" src="testing.js"></script>
|
| + <script type="application/javascript" src="start_dart.js"></script>
|
| <title>dart - TodoMVC</title>
|
| </head>
|
| <body>
|
| @@ -75,33 +79,51 @@ import 'package:unittest/unittest.dart';
|
| import 'package:web_ui/web_ui.dart';
|
| import 'example/todomvc/main.dart' as todomvc_main;
|
| import 'example/todomvc/model.dart';
|
| +import 'perf_common.dart';
|
| +import 'todomvc_common.dart';
|
|
|
| final addTodo = todomvc_main.addTodo;
|
|
|
| main() {
|
| - useShadowDom = true;
|
| + useShadowDom = false;
|
| todomvc_main.main();
|
| -
|
| window.setTimeout(() {
|
| - app.todos.add(new Todo('one (unchecked)'));
|
| - app.todos.add(new Todo('two (checked)')..done = true);
|
| - app.todos.add(new Todo('three (unchecked)'));
|
| - viewModel.showIncomplete = true;
|
| - viewModel.showDone = true;
|
| + var bench = new TodoMvcBenchmark();
|
| + bench.measure().transform(perfDone);
|
| + }, 0);
|
| +}
|
| +
|
| +class TodoMvcBenchmark extends AsyncBenchmark {
|
| + TodoMvcBenchmark() : super('todomvc-async');
|
| + Future run() {
|
| + return asyncSteps([
|
| + app.todos.clear,
|
| + () => addNote("one"),
|
| + () => addNote("two"),
|
| + () => addNote("three"),
|
| + () => addNote("four"),
|
| + () => addNote("five"),
|
| + () => markChecked(3)]);
|
| + }
|
| +}
|
| +
|
| +Future step(f) {
|
| + var completer = new Completer();
|
| + window.requestLayoutFrame(() {
|
| + var res = f();
|
| dispatch();
|
| + completer.complete(res);
|
| + });
|
| + return completer.future;
|
| +}
|
| +
|
| +Future asyncSteps(List<Function> steps) {
|
| + Future result = step(steps[0]);
|
| + for (int i = 1; i < steps.length; i++) {
|
| + result = result.chain((_) => step(steps[i]));
|
| + }
|
| + return result;
|
|
|
| - window.setTimeout(() {
|
| - viewModel.showIncomplete = true;
|
| - viewModel.showDone = false;
|
| - dispatch();
|
| - window.setTimeout(() {
|
| - viewModel.showIncomplete = true;
|
| - viewModel.showDone = true;
|
| - dispatch();
|
| - window.setTimeout(() => window.postMessage('done', '*'), 0);
|
| - }, 0);
|
| - }, 0);
|
| - }, 0);
|
| }
|
| </script>
|
| </body>
|
|
|