| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 library dart.pkg.isolate.sample.runners; | 5 library isolate.example.runner_pool; |
| 6 | 6 |
| 7 import "package:isolate/loadbalancer.dart"; | 7 import 'dart:async' show Future, Completer; |
| 8 import "package:isolate/isolaterunner.dart"; | 8 |
| 9 import "dart:async" show Future, Completer; | 9 import 'package:isolate/load_balancer.dart'; |
| 10 import 'package:isolate/isolate_runner.dart'; |
| 10 | 11 |
| 11 void main() { | 12 void main() { |
| 12 int N = 44; | 13 int N = 44; |
| 13 var sw = new Stopwatch()..start(); | 14 var sw = new Stopwatch()..start(); |
| 14 // Compute fib up to 42 with 4 isolates. | 15 // Compute fib up to 42 with 4 isolates. |
| 15 parfib(N, 4).then((v1) { | 16 parfib(N, 4).then((v1) { |
| 16 var t1 = sw.elapsedMilliseconds; | 17 var t1 = sw.elapsedMilliseconds; |
| 17 sw.stop(); | 18 sw.stop(); |
| 18 sw.reset(); | 19 sw.reset(); |
| 19 print("fib#4(${N}) = ${v1[N]}, ms: $t1"); | 20 print("fib#4(${N}) = ${v1[N]}, ms: $t1"); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 48 | 49 |
| 49 int computeFib(n) { | 50 int computeFib(n) { |
| 50 int result = fib(n); | 51 int result = fib(n); |
| 51 return result; | 52 return result; |
| 52 } | 53 } |
| 53 | 54 |
| 54 int fib(n) { | 55 int fib(n) { |
| 55 if (n < 2) return n; | 56 if (n < 2) return n; |
| 56 return fib(n - 1) + fib(n - 2); | 57 return fib(n - 1) + fib(n - 2); |
| 57 } | 58 } |
| OLD | NEW |