Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 import 'dart:scalarlist'; | |
|
kasperl
2013/02/21 11:28:15
Add copyright notice.
Cutch
2013/02/21 18:45:16
Done.
| |
| 2 | |
| 3 testLoadStore(array) { | |
| 4 Expect.equals(8, array.length); | |
| 5 Expect.isTrue(array is List<Simd128Float32>); | |
| 6 array[0] = new Simd128Float32(1.0, 2.0, 3.0, 4.0); | |
| 7 Expect.equals(1.0, array[0].x); | |
| 8 Expect.equals(2.0, array[0].y); | |
| 9 Expect.equals(3.0, array[0].z); | |
| 10 Expect.equals(4.0, array[0].w); | |
| 11 array[1] = array[0]; | |
| 12 array[0] = array[0].setX(9.0); | |
| 13 Expect.equals(9.0, array[0].x); | |
| 14 Expect.equals(2.0, array[0].y); | |
| 15 Expect.equals(3.0, array[0].z); | |
| 16 Expect.equals(4.0, array[0].w); | |
| 17 Expect.equals(1.0, array[1].x); | |
| 18 Expect.equals(2.0, array[1].y); | |
| 19 Expect.equals(3.0, array[1].z); | |
| 20 Expect.equals(4.0, array[1].w); | |
| 21 } | |
| 22 | |
| 23 testView(array) { | |
| 24 Expect.equals(8, array.length); | |
| 25 Expect.isTrue(array is List<Simd128Float32>); | |
| 26 Expect.equals(0.0, array[0].x); | |
| 27 Expect.equals(1.0, array[0].y); | |
| 28 Expect.equals(2.0, array[0].z); | |
| 29 Expect.equals(3.0, array[0].w); | |
| 30 Expect.equals(4.0, array[1].x); | |
| 31 Expect.equals(5.0, array[1].y); | |
| 32 Expect.equals(6.0, array[1].z); | |
| 33 Expect.equals(7.0, array[1].w); | |
| 34 } | |
| 35 | |
| 36 main() { | |
| 37 var list; | |
| 38 | |
| 39 list = new Simd128Float32List(8); | |
| 40 for (int i = 0; i < 3000; i++) { | |
| 41 testLoadStore(list); | |
| 42 } | |
| 43 | |
| 44 list = new Simd128Float32List.transferable(8); | |
| 45 for (int i = 0; i < 3000; i++) { | |
| 46 testLoadStore(list); | |
| 47 } | |
| 48 Float32List floatList = new Float32List(32); | |
| 49 for (int i = 0; i < floatList.length; i++) { | |
| 50 floatList[i] = i.toDouble(); | |
| 51 } | |
| 52 list = new Simd128Float32List.view(floatList.asByteArray()); | |
| 53 for (int i = 0; i < 3000; i++) { | |
| 54 testView(list); | |
| 55 } | |
| 56 for (int i = 0; i < 3000; i++) { | |
| 57 testLoadStore(list); | |
| 58 } | |
| 59 } | |
| OLD | NEW |