Index: runtime/vm/snapshot_test.dart |
diff --git a/runtime/vm/snapshot_test.dart b/runtime/vm/snapshot_test.dart |
index 58c0b3b38c04a9c1182a2a28cf46a9ec25ef2342..ad5c8c14a777c9ab4b3a682d018f961460c07f51 100644 |
--- a/runtime/vm/snapshot_test.dart |
+++ b/runtime/vm/snapshot_test.dart |
@@ -12,17 +12,13 @@ class Expect { |
} |
class Fields { |
- Fields(int i, int j) |
- : fld1 = i, |
- fld2 = j, |
- fld5 = true {} |
+ Fields(int i, int j) : fld1 = i, fld2 = j, fld5 = true {} |
int fld1; |
final int fld2; |
static int fld3; |
static const int fld4 = 10; |
bool fld5; |
} |
- |
class FieldsTest { |
static Fields testMain() { |
Fields obj = new Fields(10, 20); |
@@ -94,7 +90,8 @@ class LoopBenchmark extends BenchmarkBase { |
// This value has been copied from benchpress.js, so that we can compare |
// performance. |
var result = Loop.loop(200); |
- if (result != 20000) Error.error("Wrong result: $result. Should be: 20000"); |
+ if (result != 20000) |
+ Error.error("Wrong result: $result. Should be: 20000"); |
} |
static void main() { |
@@ -107,17 +104,14 @@ class TowersDisk { |
final int size; |
TowersDisk next; |
- TowersDisk(size) |
- : this.size = size, |
- next = null {} |
+ TowersDisk(size) : this.size = size, next = null {} |
} |
class Towers { |
List<TowersDisk> piles; |
int movesDone; |
Towers(int disks) |
- : piles = new List<TowersDisk>(3), |
- movesDone = 0 { |
+ : piles = new List<TowersDisk>(3), movesDone = 0 { |
build(0, disks); |
} |
@@ -195,12 +189,14 @@ class SieveBenchmark extends BenchmarkBase { |
for (int i = 2; i < size; i++) { |
if (flags[i]) { |
primeCount++; |
- for (int k = i + 1; k <= size; k += i) flags[k - 1] = false; |
+ for (int k = i + 1; k <= size; k += i) |
+ flags[k - 1] = false; |
} |
} |
return primeCount; |
} |
+ |
void warmup() { |
sieve(100); |
} |
@@ -209,7 +205,8 @@ class SieveBenchmark extends BenchmarkBase { |
// This value has been copied from benchpress.js, so that we can compare |
// performance. |
int result = sieve(1000); |
- if (result != 168) Error.error("Wrong result: $result should be: 168"); |
+ if (result != 168) |
+ Error.error("Wrong result: $result should be: 168"); |
} |
static void main() { |
@@ -263,7 +260,8 @@ class PermuteBenchmark extends BenchmarkBase { |
// This value has been copied from benchpress.js, so that we can compare |
// performance. |
int result = new Permute().permute(8); |
- if (result != 8660) Error.error("Wrong result: $result should be: 8660"); |
+ if (result != 8660) |
+ Error.error("Wrong result: $result should be: 8660"); |
} |
static void main() { |
@@ -276,8 +274,11 @@ class PermuteBenchmark extends BenchmarkBase { |
// lists in dart are zero-based, we stay with one-based indexing |
// (wasting one element). |
class Queens { |
- static bool tryQueens( |
- int i, List<bool> a, List<bool> b, List<bool> c, List<int> x) { |
+ static bool tryQueens(int i, |
+ List<bool> a, |
+ List<bool> b, |
+ List<bool> c, |
+ List<int> x) { |
int j = 0; |
bool q = false; |
while ((!q) && (j != 8)) { |
@@ -315,7 +316,8 @@ class Queens { |
if (i <= 7) c[i + 7] = true; |
} |
- if (!tryQueens(1, b, a, c, x)) Error.error("Error in queens"); |
+ if (!tryQueens(1, b, a, c, x)) |
+ Error.error("Error in queens"); |
} |
} |
@@ -335,6 +337,7 @@ class QueensBenchmark extends BenchmarkBase { |
} |
} |
+ |
// R e c u r s e |
class Recurse { |
static int recurse(int n) { |
@@ -362,6 +365,7 @@ class RecurseBenchmark extends BenchmarkBase { |
} |
} |
+ |
// S u m |
class SumBenchmark extends BenchmarkBase { |
const SumBenchmark() : super("Sum"); |
@@ -389,6 +393,7 @@ class SumBenchmark extends BenchmarkBase { |
} |
} |
+ |
// H e l p e r f u n c t i o n s f o r s o r t s |
class Random { |
static const int INITIAL_SEED = 74755; |
@@ -427,13 +432,15 @@ class SortData { |
void check() { |
List<int> a = list; |
int len = a.length; |
- if ((a[0] != min) || a[len - 1] != max) Error.error("List is not sorted"); |
+ if ((a[0] != min) || a[len - 1] != max) |
+ Error.error("List is not sorted"); |
for (var i = 1; i < len; i++) { |
if (a[i - 1] > a[i]) Error.error("List is not sorted"); |
} |
} |
} |
+ |
// B u b b l e S o r t |
class BubbleSort { |
static void sort(List<int> a) { |
@@ -516,6 +523,7 @@ class QuickSortBenchmark extends BenchmarkBase { |
} |
} |
+ |
// T r e e S o r t |
class TreeNodePress { |
int value; |
@@ -526,15 +534,11 @@ class TreeNodePress { |
void insert(int n) { |
if (n < value) { |
- if (left == null) |
- left = new TreeNodePress(n); |
- else |
- left.insert(n); |
+ if (left == null) left = new TreeNodePress(n); |
+ else left.insert(n); |
} else { |
- if (right == null) |
- right = new TreeNodePress(n); |
- else |
- right.insert(n); |
+ if (right == null) right = new TreeNodePress(n); |
+ else right.insert(n); |
} |
} |
@@ -544,7 +548,7 @@ class TreeNodePress { |
int value = this.value; |
return ((left == null) || ((left.value < value) && left.check())) && |
- ((right == null) || ((right.value >= value) && right.check())); |
+ ((right == null) || ((right.value >= value) && right.check())); |
} |
} |
@@ -571,6 +575,7 @@ class TreeSortBenchmark extends BenchmarkBase { |
} |
} |
+ |
// T a k |
class TakBenchmark extends BenchmarkBase { |
const TakBenchmark() : super("Tak"); |
@@ -595,14 +600,15 @@ class TakBenchmark extends BenchmarkBase { |
} |
} |
+ |
// T a k l |
class ListElement { |
final int length; |
final ListElement next; |
const ListElement(int length, ListElement next) |
- : this.length = length, |
- this.next = next; |
+ : this.length = length, |
+ this.next = next; |
static ListElement makeList(int length) { |
if (length == 0) return null; |
@@ -624,7 +630,9 @@ class ListElement { |
class Takl { |
static ListElement takl(ListElement x, ListElement y, ListElement z) { |
if (ListElement.isShorter(y, x)) { |
- return takl(takl(x.next, y, z), takl(y.next, z, x), takl(z.next, x, y)); |
+ return takl(takl(x.next, y, z), |
+ takl(y.next, z, x), |
+ takl(z.next, x, y)); |
} else { |
return z; |
} |
@@ -635,15 +643,17 @@ class TaklBenchmark extends BenchmarkBase { |
const TaklBenchmark() : super("Takl"); |
void warmup() { |
- Takl.takl(ListElement.makeList(8), ListElement.makeList(4), |
- ListElement.makeList(3)); |
+ Takl.takl(ListElement.makeList(8), |
+ ListElement.makeList(4), |
+ ListElement.makeList(3)); |
} |
void exercise() { |
// This value has been copied from benchpress.js, so that we can compare |
// performance. |
ListElement result = Takl.takl(ListElement.makeList(15), |
- ListElement.makeList(10), ListElement.makeList(6)); |
+ ListElement.makeList(10), |
+ ListElement.makeList(6)); |
if (result.length != 10) { |
int len = result.length; |
Error.error("Wrong result: $len should be: 10"); |
@@ -660,19 +670,19 @@ class TaklBenchmark extends BenchmarkBase { |
class BenchPress { |
static void mainWithArgs(List<String> args) { |
List<BenchmarkBase> benchmarks = [ |
- new BubbleSortBenchmark(), |
- new FibBenchmark(), |
- new LoopBenchmark(), |
- new PermuteBenchmark(), |
- new QueensBenchmark(), |
- new QuickSortBenchmark(), |
- new RecurseBenchmark(), |
- new SieveBenchmark(), |
- new SumBenchmark(), |
- new TakBenchmark(), |
- new TaklBenchmark(), |
- new TowersBenchmark(), |
- new TreeSortBenchmark(), |
+ new BubbleSortBenchmark(), |
+ new FibBenchmark(), |
+ new LoopBenchmark(), |
+ new PermuteBenchmark(), |
+ new QueensBenchmark(), |
+ new QuickSortBenchmark(), |
+ new RecurseBenchmark(), |
+ new SieveBenchmark(), |
+ new SumBenchmark(), |
+ new TakBenchmark(), |
+ new TaklBenchmark(), |
+ new TowersBenchmark(), |
+ new TreeSortBenchmark(), |
]; |
if (args.length > 0) { |
String benchName = args[0]; |
@@ -714,7 +724,7 @@ class BenchmarkBase { |
// The benchmark code. |
// This function is not used, if both [warmup] and [exercise] are overwritten. |
- void run() {} |
+ void run() { } |
// Runs a short version of the benchmark. By default invokes [run] once. |
void warmup() { |
@@ -729,10 +739,10 @@ class BenchmarkBase { |
} |
// Not measured setup code executed prior to the benchmark runs. |
- void setup() {} |
+ void setup() { } |
// Not measures teardown code executed after the benchark runs. |
- void teardown() {} |
+ void teardown() { } |
// Measures the score for this benchmark by executing it repeately until |
// time minimum has been reached. |
@@ -753,13 +763,9 @@ class BenchmarkBase { |
double measure() { |
setup(); |
// Warmup for at least 100ms. Discard result. |
- measureFor(() { |
- this.warmup(); |
- }, -100); |
+ measureFor(() { this.warmup(); }, -100); |
// Run the benchmark for at least 2000ms. |
- double result = measureFor(() { |
- this.exercise(); |
- }, -2000); |
+ double result = measureFor(() { this.exercise(); }, -2000); |
teardown(); |
return result; |
} |
@@ -768,22 +774,24 @@ class BenchmarkBase { |
double score = measure(); |
print("name: $score"); |
} |
-} |
+} |
class Logger { |
static print(object) { |
printobject(object); |
} |
- |
- static printobject(obj) {} |
+ static printobject(obj) { } |
} |
+ |
// |
// Dromaeo ObjectString |
// Adapted from Mozilla JavaScript performance test suite. |
// Microtests of strings (concatenation, methods). |
+ |
class ObjectString extends BenchmarkBase { |
+ |
const ObjectString() : super("Dromaeo.ObjectString"); |
static void main() { |
@@ -797,8 +805,8 @@ class ObjectString extends BenchmarkBase { |
String getRandomString(int characters) { |
var result = ""; |
for (var i = 0; i < characters; i++) { |
- result += |
- Strings.createFromCodePoints([(25 * Math.random()).toInt() + 97]); |
+ result += Strings. |
+ createFromCodePoints([(25 * Math.random()).toInt() + 97]); |
} |
result += result; |
result += result; |
@@ -915,6 +923,7 @@ class NumberBenchmark { |
} |
} |
+ |
class CodeUnitAtBenchmark { |
CodeUnitAtBenchmark() {} |
@@ -972,7 +981,7 @@ class SliceBenchmark { |
str = input.substring(input.length - 1, input.length - 1); |
str = input.substring(input.length - 6, input.length - 1); |
str = input.substring(150, 155); //set to 15000 and 15005 |
- str = input.substring(120, input.length - 1); //set to 12000 |
+ str = input.substring(120, input.length-1); //set to 12000 |
} |
return str; |
} |
@@ -984,7 +993,7 @@ class SubstrBenchmark { |
static String test(String input, var iterations) { |
var str; |
for (var j = 0; j < iterations; j++) { |
- str = input.substring(0, input.length - 1); |
+ str = input.substring(0, input.length-1); |
str = input.substring(0, 4); |
str = input.substring(input.length - 1, input.length - 1); |
str = input.substring(input.length - 6, input.length - 6); |
@@ -1009,6 +1018,7 @@ class SubstringBenchmark { |
str = input.substring(120, input.length - 2); //set to 12000 |
} |
return str; |
+ |
} |
} |
@@ -1055,6 +1065,7 @@ class ComparingBenchmark { |
// Benchmarks basic message communication between two isolates. |
class Benchmark1 { |
+ |
static const MESSAGES = 10000; |
static const INIT_MESSAGE = 0; |
static const TERMINATION_MESSAGE = -1; |
@@ -1062,6 +1073,7 @@ class Benchmark1 { |
static const RUN_TIME = 1000; |
static const RUNS = 5; |
+ |
static int run() { |
return _run; |
} |
@@ -1090,6 +1102,7 @@ class Benchmark1 { |
} |
class PingPongGame { |
+ |
PingPongGame() |
: _ping = new ReceivePort(), |
_pingPort = _ping.toSendPort(), |
@@ -1164,6 +1177,7 @@ void pong() { |
}); |
} |
+ |
class ManyGenericInstanceofTest { |
static testMain() { |
for (int i = 0; i < 5000; i++) { |
@@ -1211,7 +1225,7 @@ isolate_negative_test_main() { |
test("ensure isolate code is executed", () { |
SendPort port = spawnFunction(isolate_negative_entry); |
port.call("foo").then(expectAsync1((message) { |
- Expect.equals(true, "Expected fail"); // <=-------- Should fail here. |
+ Expect.equals(true, "Expected fail"); // <=-------- Should fail here. |
})); |
}); |
} |
@@ -1229,21 +1243,14 @@ class MessageTest { |
static const List list2 = const [null, list1, list1, list1, list1]; |
static const List list3 = const [list2, 2.0, true, false, 0xfffffffffff]; |
static const Map map1 = const { |
- "a=1": 1, |
- "b=2": 2, |
- "c=3": 3, |
+ "a=1" : 1, "b=2" : 2, "c=3" : 3, |
}; |
static const Map map2 = const { |
- "list1": list1, |
- "list2": list2, |
- "list3": list3, |
+ "list1" : list1, "list2" : list2, "list3" : list3, |
}; |
static const List list4 = const [map1, map2]; |
static const List elms = const [ |
- list1, |
- list2, |
- list3, |
- list4, |
+ list1, list2, list3, list4, |
]; |
static void VerifyMap(Map expected, Map actual) { |
@@ -1257,7 +1264,6 @@ class MessageTest { |
Expect.equals(value, actual[key]); |
} |
} |
- |
expected.forEach(testForEachMap); |
} |
@@ -1314,7 +1320,7 @@ message_test_main() { |
// Send recursive objects and receive them back. |
List local_list1 = ["Hello", "World", "Hello", 0xffffffffff]; |
- List local_list2 = [null, local_list1, local_list1]; |
+ List local_list2 = [null, local_list1, local_list1 ]; |
List local_list3 = [local_list2, 2.0, true, false, 0xffffffffff]; |
List sendObject = new List(5); |
sendObject[0] = local_list1; |
@@ -1338,8 +1344,8 @@ message_test_main() { |
// Shutdown the MessageServer. |
remote.call(-1).then(expectAsync1((int message) { |
- Expect.equals(MessageTest.elms.length + 1, message); |
- })); |
+ Expect.equals(MessageTest.elms.length + 1, message); |
+ })); |
}); |
} |
@@ -1416,6 +1422,7 @@ void count_main() { |
}); |
} |
+ |
// --------------------------------------------------------------------------- |
// tests/isolate/mandel_isolate_test.dart |
// --------------------------------------------------------------------------- |
@@ -1434,7 +1441,9 @@ mandel_main() { |
}); |
} |
+ |
class MandelbrotState { |
+ |
MandelbrotState() { |
_result = new List<List<int>>(N); |
_lineProcessedBy = new List<LineProcessorClient>(N); |
@@ -1492,7 +1501,9 @@ class MandelbrotState { |
Completer<bool> _validated; |
} |
+ |
class LineProcessorClient { |
+ |
LineProcessorClient(MandelbrotState this._state, int this._id) { |
_port = spawnFunction(processLines); |
} |