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

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

Issue 1414483010: Dart: Use a RawReceivePort to receive events for Mojo handles. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « benchmarks/mojo_rtt_benchmark/lib/isolate.dart ('k') | examples/dart/netcat/lib/main.dart » ('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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 if (argResults["cpp-server"]) { 47 if (argResults["cpp-server"]) {
48 echoUrl = "mojo:echo_server"; 48 echoUrl = "mojo:echo_server";
49 } 49 }
50 _numClients = int.parse(argResults["num-clients"]); 50 _numClients = int.parse(argResults["num-clients"]);
51 _numActiveClients = int.parse(argResults["num-active-clients"]); 51 _numActiveClients = int.parse(argResults["num-active-clients"]);
52 52
53 // Setup the connection to the echo app. 53 // Setup the connection to the echo app.
54 for (int i = 0; i < _numClients; i++) { 54 for (int i = 0; i < _numClients; i++) {
55 var newProxy = new EchoProxy.unbound(); 55 var newProxy = new EchoProxy.unbound();
56 newProxy.errorFuture.then((e) { 56 newProxy.errorFuture.then((e) {
57 _errorHandler(); 57 _errorHandler(e);
58 }); 58 });
59 connectToService(echoUrl, newProxy); 59 connectToService(echoUrl, newProxy);
60 _echoProxies.add(newProxy); 60 _echoProxies.add(newProxy);
61 } 61 }
62 62
63 // Start echoing. 63 // Start echoing.
64 _doEcho = true; 64 _doEcho = true;
65 Timer.run(() => _run(0)); 65 Timer.run(() => _run(0));
66 66
67 // Begin tracing echo rtts after waiting for kWarmupDuration. 67 // Begin tracing echo rtts after waiting for kWarmupDuration.
(...skipping 24 matching lines...) Expand all
92 int end = getTimeTicksNow(); 92 int end = getTimeTicksNow();
93 _tracing.traceDuration("ping", "mojo_rtt_benchmark", start, end); 93 _tracing.traceDuration("ping", "mojo_rtt_benchmark", start, end);
94 return r; 94 return r;
95 }); 95 });
96 } 96 }
97 97
98 Future _echo(int idx, String s) { 98 Future _echo(int idx, String s) {
99 return _echoProxies[idx].ptr.echoString(s); 99 return _echoProxies[idx].ptr.echoString(s);
100 } 100 }
101 101
102 _errorHandler() { 102 _errorHandler(Object e) {
103 _doEcho = false; 103 _doEcho = false;
104 return Future.wait(_echoProxies.map((p) => p.close())).then((_) { 104 return Future.wait(_echoProxies.map((p) => p.close())).then((_) {
105 MojoHandle.reportLeakedHandles(); 105 MojoHandle.reportLeakedHandles();
106 }); 106 });
107 } 107 }
108 } 108 }
109 109
110 main(List args) { 110 main(List args) {
111 MojoHandle appHandle = new MojoHandle(args[0]); 111 MojoHandle appHandle = new MojoHandle(args[0]);
112 new EchoTracingApp.fromHandle(appHandle); 112 new EchoTracingApp.fromHandle(appHandle);
113 } 113 }
OLDNEW
« no previous file with comments | « benchmarks/mojo_rtt_benchmark/lib/isolate.dart ('k') | examples/dart/netcat/lib/main.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698