Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: examples/dart/mojo_rtt_benchmark/lib/main.dart

Issue 1405103002: Dart: Merge message pipe query and read into one native call. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | mojo/dart/embedder/mojo_natives.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // This Mojo app is a benchmark of Mojo/Dart IPC Round Trip Times. 5 // This Mojo app is a benchmark of Mojo/Dart IPC Round Trip Times.
6 // It creates many proxies from a single isolate, and makes requests using those 6 // It creates many proxies from a single isolate, and makes requests using those
7 // proxies round-robin. 7 // proxies round-robin.
8 // To run it, and the other RTT benchmarks: 8 // To run it, and the other RTT benchmarks:
9 // 9 //
10 // $ ./mojo/devtools/common/mojo_benchmark [--release] mojo/tools/data/rtt_bench marks 10 // $ ./mojo/devtools/common/mojo_benchmark [--release] mojo/tools/data/rtt_bench marks
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 _run(int idx) { 70 _run(int idx) {
71 if (idx == _numActiveClients) { 71 if (idx == _numActiveClients) {
72 idx = 0; 72 idx = 0;
73 } 73 }
74 if (_doEcho) { 74 if (_doEcho) {
75 if (_warmup) { 75 if (_warmup) {
76 _echo(idx, "ping").then((_) => new Timer(kDelay, () => _run(idx + 1))); 76 _echo(idx, "ping").then((_) => new Timer(kDelay, () => _run(idx + 1)));
77 } else { 77 } else {
78 _tracedEcho(idx).then((_) => new Timer(kDelay, () => _run(idx + 1))); 78 _tracedEcho(idx, "ping")
79 .then((_) => new Timer(kDelay, () => _run(idx + 1)));
79 } 80 }
80 } 81 }
81 } 82 }
82 83
83 Future _tracedEcho(int idx) { 84 Future _tracedEcho(int idx, String s) {
84 int start = getTimeTicksNow(); 85 int start = getTimeTicksNow();
85 return _echo(idx, "ping").then((_) { 86 return _echo(idx, s).then((_) {
86 int end = getTimeTicksNow(); 87 int end = getTimeTicksNow();
87 _tracing.traceDuration("ping", "mojo_rtt_benchmark", start, end); 88 _tracing.traceDuration("ping", "mojo_rtt_benchmark", start, end);
88 }); 89 });
89 } 90 }
90 91
91 Future _echo(int idx, String s) { 92 Future _echo(int idx, String s) {
92 return _echoProxies[idx] 93 return _echoProxies[idx]
93 .ptr 94 .ptr
94 .echoString(s) 95 .echoString(s)
95 .catchError((e) => _errorHandler()); 96 .catchError((e) => _errorHandler());
96 } 97 }
97 98
98 _errorHandler() { 99 _errorHandler() {
99 _doEcho = false; 100 _doEcho = false;
100 return Future.wait(_echoProxies.map((p) => p.close())).then((_) { 101 return Future.wait(_echoProxies.map((p) => p.close())).then((_) {
101 assert(MojoHandle.reportLeakedHandles()); 102 assert(MojoHandle.reportLeakedHandles());
102 }); 103 });
103 } 104 }
104 } 105 }
105 106
106 main(List args) { 107 main(List args) {
107 MojoHandle appHandle = new MojoHandle(args[0]); 108 MojoHandle appHandle = new MojoHandle(args[0]);
108 new EchoTracingApp.fromHandle(appHandle); 109 new EchoTracingApp.fromHandle(appHandle);
109 } 110 }
OLDNEW
« no previous file with comments | « no previous file | mojo/dart/embedder/mojo_natives.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698