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

Side by Side Diff: tools/full-coverage.dart

Issue 140303008: Fairly partition work in tools/full-coverage.dart. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import "dart:async"; 5 import "dart:async";
6 import "dart:convert"; 6 import "dart:convert";
7 import "dart:io"; 7 import "dart:io";
8 import "dart:isolate"; 8 import "dart:isolate";
9 9
10 import "package:args/args.dart"; 10 import "package:args/args.dart";
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 files.forEach((File fileEntry) { 264 files.forEach((File fileEntry) {
265 // Read file sync, as it only contains 1 object. 265 // Read file sync, as it only contains 1 object.
266 String contents = fileEntry.readAsStringSync(); 266 String contents = fileEntry.readAsStringSync();
267 if (contents.length > 0) { 267 if (contents.length > 0) {
268 mergeHitmaps(createHitmap(contents, resolver), workerHitmap); 268 mergeHitmaps(createHitmap(contents, resolver), workerHitmap);
269 } 269 }
270 }); 270 });
271 271
272 if (env["verbose"]) { 272 if (env["verbose"]) {
273 final end = new DateTime.now().millisecondsSinceEpoch; 273 final end = new DateTime.now().millisecondsSinceEpoch;
274 print("${msg.workerName}: Finished processing files. " 274 print("${msg.workerName}: Finished processing ${files.length} files. "
275 "Took ${end - start} ms."); 275 "Took ${end - start} ms.");
276 } 276 }
277 277
278 msg.replyPort.send(new ResultMessage(workerHitmap, resolver.failed)); 278 msg.replyPort.send(new ResultMessage(workerHitmap, resolver.failed));
279 } 279 }
280 280
281 class WorkMessage { 281 class WorkMessage {
282 final String workerName; 282 final String workerName;
283 final Map environment; 283 final Map environment;
284 final List files; 284 final List files;
285 final SendPort replyPort; 285 final SendPort replyPort;
286 WorkMessage(this.workerName, this.environment, this.files, this.replyPort); 286 WorkMessage(this.workerName, this.environment, this.files, this.replyPort);
287 } 287 }
288 288
289 class ResultMessage { 289 class ResultMessage {
290 final hitmap; 290 final hitmap;
291 final failedResolves; 291 final failedResolves;
292 ResultMessage(this.hitmap, this.failedResolves); 292 ResultMessage(this.hitmap, this.failedResolves);
293 } 293 }
294 294
295 final env = new Environment(); 295 final env = new Environment();
296 296
297 List<List> split(List list, int nBuckets) { 297 List<List> split(List list, int nBuckets) {
298 // Leftover goes in the last bucket.
299 // TODO(16505): Do a fair split.
300 var buckets = new List(nBuckets); 298 var buckets = new List(nBuckets);
301 var bucketSize = list.length ~/ nBuckets; 299 var bucketSize = list.length ~/ nBuckets;
300 var leftover = list.length % nBuckets;
302 var taken = 0; 301 var taken = 0;
302 var start = 0;
303 for (int i = 0; i < nBuckets; i++) { 303 for (int i = 0; i < nBuckets; i++) {
304 bool lastBucket = i + 1 == nBuckets; 304 var end = (i < leftover) ? (start + bucketSize + 1) : (start + bucketSize);
305 var start = i * bucketSize;
306 var end = lastBucket ? list.length : start + bucketSize ;
307 buckets[i] = list.sublist(start, end); 305 buckets[i] = list.sublist(start, end);
308 taken += buckets[i].length; 306 taken += buckets[i].length;
307 start = end;
309 } 308 }
310 if (taken != list.length) throw "Error splitting"; 309 if (taken != list.length) throw "Error splitting";
311 return buckets; 310 return buckets;
312 } 311 }
313 312
314 Future<ResultMessage> spawnWorker(name, environment, files) { 313 Future<ResultMessage> spawnWorker(name, environment, files) {
315 RawReceivePort port = new RawReceivePort(); 314 RawReceivePort port = new RawReceivePort();
316 var completer = new Completer(); 315 var completer = new Completer();
317 port.handler = ((ResultMessage msg) { 316 port.handler = ((ResultMessage msg) {
318 completer.complete(msg); 317 completer.complete(msg);
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 } 493 }
495 494
496 try { 495 try {
497 env.workers = int.parse("${args["workers"]}"); 496 env.workers = int.parse("${args["workers"]}");
498 } catch (e) { 497 } catch (e) {
499 fail("Invalid worker count: $e"); 498 fail("Invalid worker count: $e");
500 } 499 }
501 500
502 env.verbose = args["verbose"]; 501 env.verbose = args["verbose"];
503 } 502 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698